#include<stdio.h>
#include<string.h>
#define maxn 202
struct ss
{
int v,w;
int next;
}edge[maxn];
int top;
int head[maxn];
void add(int u,int v,int w)
{
edge[top].v=v;
edge[top].w=w;
edge[top].next=head[u];
head[u]=top++;
}
void print(int i)
{
for(int u=head[i];u!=0;u=edge[u].next)
printf("%d %d %d \n",i,edge[u].v,edge[u].w);
}
int main()
{
//freopen("Input.txt","r",stdin);
int n,m;
while(~scanf("%d%d",&n,&m))
{
memset(head,0,sizeof(head));
top=1;
int a,b,c;
while(m--)
{
scanf("%d%d%d",&a,&b,&c);
add(a,b,c);
}
scanf("%d",&m);
while(m--)
{
scanf("%d",&a);
print(a);
}
}
return 0;
}
链式向前星--邻接表存储图
最新推荐文章于 2022-06-22 17:25:09 发布