标签:ref 复习 clu sizeof https \n i++ ret online
https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2872/pid/3116
//因为 顶点少 所以可以用邻接矩阵存图
#include <stdio.h>
#include <stdlib.h>
char G[5111][5111];
int main()
{
int n, m;
while(~scanf("%d %d", &n, &m))
{
memset(G, -1, sizeof(G));
int i;
for(i = 0;i < m;i++)
{
int u,v;
scanf("%d %d", &u, &v);
G[u][v] = 1;
}
long q;
scanf("%ld", &q);
while(q--)
{
int u, v;
scanf("%d %d", &u, &v);
if(G[u][v]!= -1)printf("Yes\n");
else printf("No\n");
}
}
return 0;
}
图的存储(复习)——3116 SDUT图的基本存储的基本方式一
标签:ref 复习 clu sizeof https \n i++ ret online
原文地址:https://www.cnblogs.com/TJack/p/10747725.html