代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,e,i,j,x,y;
cin>>n >> e;
vector<vector<int>> adj(n+1);
for(i=0;i<e;++i)
{
cin>>x>>y;
adj[x].push_back(y);
}
for(i=1;i<=n;++i)
sort(adj[i].begin(),adj[i].end());
for(i=1;i<=n;++i)
{
if(!adj[i].empty())
{
cout<<i<<endl;
for(int j:adj[i])
cout<<j<<" ";
cout<<endl;
}
}
return 0;
}