n表示点的个数,m表示边的条数。
#include<iostream>
#include<cstring>
using namespace std;
struct node
{
int v;
int next;
}a[1001];
int n,m,tot,head[1001];
void edd_edge(int u,int v)
{
a[tot].v=v;
a[tot].next=head[u];
head[u]=tot++;
}
int main()
{
memset(head,-1,sizeof(head));
int x,y;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>x>>y;
add_edge(x,y);
}
return 0;
}