「日常训练」Regular Bridge(Codeforces Round 306 Div.2 D)

题意与分析

图论基础+思维题。

代码

#include <bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (repType i = (a); i <= (b); ++i)
#define per(i, a, b) for (repType i = (a); i >= (b); --i)
#define QUICKIO                  
    ios::sync_with_stdio(false); 
    cin.tie(0);                  
    cout.tie(0);
using namespace std;
using ll=long long;
using repType=int;

int main()
{
	int k; cin>>k;
	if(k%2==0) cout<<"NO"<<endl;
	else 
	{
		cout<<"YES"<<endl;
		cout<<4*k-2<<" "<<2*k*(k-1)+k<<endl;
		cout<<1<<" "<<2<<endl;
		rep(i,3,3+k-1-1) cout<<1<<" "<<i<<endl;
		rep(i,k+2,k+2+k-1-1) cout<<2<<" "<<i<<endl; // k+2 ~ 2*k
		rep(i,3,3+k-1-1)
		{
			rep(j,2*k+1,2*k+1+k-1-1) // 2*k+1 ~ 3*k-1
			{
				cout<<i<<" "<<j<<endl;
			}
		}
		rep(i,k+2,2*k)
		{
			rep(j,3*k,3*k+k-1-1) // 3*k ~ 4*k-2
			{
				cout<<i<<" "<<j<<endl;
			}
		}
		for(int i=2*k+1;i<=3*k-1;i+=2)
		{
			cout<<i<<" "<<i+1<<endl;
		}
		for(int i=3*k;i<=4*k-2;i+=2)
		{
			cout<<i<<" "<<i+1<<endl;
		}

	}
	return 0;
}
如非注明,原创内容遵循GFDLv1.3发布;其中的代码遵循GPLv3发布。
原文地址:https://www.cnblogs.com/samhx/p/cfr306d2d.html