首页 > 其他 > 详细

图的存储(复习)——3116 SDUT图的基本存储的基本方式一

时间:2019-04-22 00:27:34      阅读:166      评论:0      收藏:0      [点我收藏+]

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图的基本存储的基本方式一

原文:https://www.cnblogs.com/TJack/p/10747725.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!