550D - Regular Bridge - CodeForces Solution


constructive algorithms graphs implementation *1900

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	// freopen("wormhole.in","r",stdin);
	// freopen("wormhole.out","w",stdout);

	int k; cin >> k;

	if(k%2==0){
		cout << "NO\n";
		return 0;
	}

	cout << "YES\n";
	if(k==1){
		cout << 2 << " " << 1 << "\n";
		cout << 1 << " " << 2 << "\n";
		return 0;
	}

	cout << 2*k+4 << " " << (2*k+4)*k/2 << "\n";

	cout << 1 << " " << k+3 << "\n";
	for(int i=1;i<=k+1;i++){
		for(int j=i+1;j<=k+1;j++){
			if(i%2==1 && j==i+1) continue;

			cout << i << " " << j << "\n";
		}
	}

	for(int i=2;i<=k+1;i++) cout << i << " " << k+2 << "\n";

	for(int i=k+3;i<=2*k+3;i++){
		for(int j=i+1;j<=2*k+3;j++){
			if(i%2==0 && j==i+1) continue;

			cout << i << " " << j << "\n";
		}
	}

	for(int i=k+4;i<2*k+4;i++) cout << i << " " << 2*k+4 << "\n";
	return 0;
}


Comments

Submit
0 Comments
More Questions

230A - Dragons
200B - Drinks
13A - Numbers
129A - Cookies
1367B - Even Array
136A - Presents
1450A - Avoid Trygub
327A - Flipping Game
411A - Password Check
1520C - Not Adjacent Matrix
1538B - Friends and Candies
580A - Kefa and First Steps
1038B - Non-Coprime Partition
43A - Football
50A - Domino piling
479A - Expression
1480A - Yet Another String Game
1216C - White Sheet
1648A - Weird Sum
427A - Police Recruits
535A - Tavas and Nafas
581A - Vasya the Hipster
1537B - Bad Boy
1406B - Maximum Product
507B - Amr and Pins
379A - New Year Candles
1154A - Restoring Three Numbers
750A - New Year and Hurry
705A - Hulk
492B - Vanya and Lanterns