题目毁灭者.黄题篇.无向无权图存储1
2025-08-18 17:09:42
发布于:浙江
4阅读
0回复
0点赞
简单的邻接矩阵存储,注意无向图的邻接矩阵是沿着对角线对称的
#include<bits/stdc++.h>
using namespace std;
short int mp[101][101];
int main(){
short int n,m,q;
cin>>n>>m>>q;
for(short int i=1;i<=m;i++){
short int x,y;
cin>>x>>y;
mp[x][y]=1;
mp[y][x]=1;
}
for(short int i=1;i<=q;i++){
short int x,y;
cin>>x>>y;
if(mp[x][y]||mp[y][x]){
cout<<"Cancel"<<endl;
}
else{
cout<<"Accepted"<<endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个