1 条题解
-
1tywz272ghw LV 4 @ 2018-02-08 16:30:26
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int maxN=10000+5;
vector<int> toNode[maxN];
int N,M;
int main()
{
scanf("%d%d",&N,&M);
for (int i=0;i<M;i++)
{
int u,v;
scanf("%d%d",&u,&v);
toNode[u].push_back(v);
toNode[v].push_back(u);
}
for (int i=1;i<=N;i++)
sort(toNode[i].begin(),toNode[i].end());
for (int i=1;i<=N;i++)
{
printf("%d",i);
for(int j=0;j<toNode[i].size();j++)
{
printf("%d",toNode[i][j]);
}
putchar('\n');
}
return 0;
- 1