#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node
{
int to,next;
}Edge[100005];
bool my_list[1005][1005];
int new_edge,n,m,x,y,head[100005];
void add_edge(int from,int to)
{
Edge[++new_edge].next=head[from];
Edge[new_edge].to=to;
head[from]=new_edge;
}
signed main()
{
scanf("%lld%lld",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%lld%lld",&x,&y);
my_list[x][y]=1;
my_list[y][x]=1;
add_edge(x,y);
add_edge(y,x);
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cout<<my_list[i][j]<<" ";
printf("\n");
}
for(int i=1;i<=n;i++)
{
int c[100005]={0},cnt=0;
for(int j=head[i];j;j=Edge[j].next)
{
c[++cnt]=Edge[j].to;
}
sort(c+1,c+cnt+1);
printf("%lld ",cnt);
for(int j=1;j<=cnt;j++)
printf("%lld ",c[j]);
printf("\n");
}
return 0;
}
30pts其他RE了,帮忙看看为啥?