CF192div2-330B

题意:给定n个城市并建造马路是的两两到达,且距离不能超过2

因为0<=m<n/2,所以必然存在某个城市是无限制的,那就可以以这个无限制的城市为中心建造。。。。

只要想通了真尼玛简单。。。。。。没想通真烦。。。。。。。。。。

 1 #include<stdio.h>
 2 #include<string.h>
 3 const int maxn = 1005;
 4 int ind[ maxn ];
 5 int main(){
 6     int n,m;
 7     while( scanf("%d%d",&n,&m)==2 ){
 8         memset( ind,0,sizeof( ind ) );
 9         int a,b;
10         while( m-- ){
11             scanf("%d%d",&a,&b);
12             ind[a]++;
13             ind[b]++;
14         }
15         int f;
16         for( int i=1;i<=n;i++ ){
17             if( ind[i]==0 ){
18                 f = i;
19                 break;
20             }
21         }
22         printf("%d
",n-1);
23         for( int i=1;i<=n;i++ ){
24             if( i==f ) continue;
25             printf("%d %d
",f,i);
26         }
27     }
28     return 0;
29 }
View Code
keep moving...
原文地址:https://www.cnblogs.com/xxx0624/p/3203791.html