题意:
思路:
1 #include<cstdio> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 #include<map> 8 #include<set> 9 #include<queue> 10 #include<vector> 11 using namespace std; 12 typedef long long ll; 13 typedef unsigned int uint; 14 typedef unsigned long long ull; 15 typedef pair<int,int> PII; 16 typedef vector<int> VI; 17 #define fi first 18 #define se second 19 #define MP make_pair 20 #define N 1100 21 #define M 1100 22 #define MOD 2147493647 23 #define eps 1e-8 24 #define pi acos(-1) 25 26 int c[N][N]; 27 28 int main() 29 { 30 // freopen("C.in","r",stdin); 31 // freopen("C.out","w",stdout); 32 int n,m; 33 scanf("%d%d",&n,&m); 34 for(int i=1;i<=n;i++) c[i][++c[i][0]]=i; 35 for(int i=1;i<=m;i++) 36 { 37 int x,y; 38 scanf("%d%d",&x,&y); 39 c[x][++c[x][0]]=x*1000+y; 40 c[y][++c[y][0]]=x*1000+y; 41 } 42 for(int i=1;i<=n;i++) 43 { 44 printf("%d ",c[i][0]); 45 for(int j=1;j<=c[i][0];j++) printf("%d %d ",i,c[i][j]); 46 } 47 return 0; 48 }