Codeforce 550 D Regular Bridge

Source: Internet
Author: User

Test instructions: Create a connected graph with a degree of K for all points and at least one bridge.


Practice: First build a bridge, and then on both sides of the bridge to establish two degrees K-connected graph, through the bridge to join together.


It is clear that K is even when there is no solution.






#include <map> #include <string> #include <cstring> #include <cstdio> #include <cstdlib># include<cmath> #include <queue> #include <vector> #include <iostream> #include <algorithm > #include <bitset> #include <climits> #include <list> #include <iomanip> #include <stack > #include <set>using namespace std;int main () {int n;cin>>n;if (n%2==0) {puts ("NO"); return 0;} Puts ("YES"), if (n==1) {printf ("2 1\n1 2"); return 0;} n++;cout<<2*n+2<< ""; if (n&1) cout<<n*n<<endl;elsecout<<n*n-1<<endl;for ( int i=1;i<=n;i++) {if (i<n-1) {cout<<i<< "" <<2*n+1<<endl;cout<<i+n<< "" <<2*n+2<<endl;} if (i==n-1) {cout<<i<< "" <<i+1<<endl;cout<<i+n<< "" &LT;&LT;I+1+N&LT;&LT;ENDL;} for (int j=i+1;j<=n;j++) {if (!) ( (i&1) &&j==i+1) {cout<<i<< "<<j<<endl;cout<<i+n<<" "<<j+n <<endl;}}}cout<<2*n+1<< "" <<2*n+2<<endl;} 

Time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

An undirected graph was called K-regular, if the degrees of all their vertices is equal K. An edge of a connected graph was called a bridge, if after removing it the graph was being split into the other connected Components.

Build a connected undirected k-regular graph containing at least one bridge, or else state that such graph doesn ' T exist.

Input

The single line of the input contains integer k (1?≤? K.≤?100)-the required degree of the vertices of the regular graph.

Output

Print "NO" (without quotes), if such graph doesn ' t exist.

Otherwise, print "YES" in the first line and the description for any suitable graph in the next lines.

The description of the made graph must start with numbers n and m -the number of vertices and edges res Pectively.

Each of the nextmLines must contain, integers,aandb(1?≤? a,? b? ≤? N , a? ≠? b ), that's mean that there was an edge connecting the verticesaandb. A graph shouldn ' t contain multiple edges and edges that leads from a vertex to itself. A graph must is connected, the degrees of all vertices of the graph must be equalk. At least one edge of the graph must is a bridge. You can print the edges of the graph in any order. You can print the ends of each edge in any order.

The constructed graph must contain at mostTen6 Vertices andTen6 Edges (It is guaranteed so if at least one graph that meets the requirements exists and then there also exists the graph WI Th at mostTen6 Vertices and at the mostTen6 edges).

Sample Test (s) input
1
Output
YES2 11 2
Note

The sample from the statement there is a suitable graph consisting of the vertices, connected by a single edge.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Codeforce 550 D Regular Bridge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.