HDU-1829
来源:互联网 发布:java中间件框架 编辑:程序博客网 时间:2024/04/28 00:51
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>#include <set>#include <queue>using namespace std;int a[2005][2005];int v[2005];int n,m;queue<int>Q;int ans=0;void BFS(int i){ Q.push(i); while(!Q.empty()){ int t=Q.front(); Q.pop(); for(int i=0;i<n;i++) if(a[t][i]==1){ if(v[i]==0){ v[i]=v[t]*(-1); Q.push(i); } else if(v[i]==v[t]){ ans=1; } } }}int main(){ int T; cin>>T; int CASE=1; while(T--){ ans=0; scanf("%d%d",&n,&m); int i,j; int t1,t2; for(i=0;i<m;i++){ scanf("%d%d",&t1,&t2); a[t1-1][t2-1]=1; a[t2-1][t1-1]=1; } while(!Q.empty())Q.pop(); for(i=0;i<n&&ans==0;i++){ if(v[i]==0){ v[i]=1; BFS(i); } } printf("Scenario #%d:\n",CASE++); if(ans==1)printf("Suspicious bugs found!\n"); else printf("No suspicious bugs found!\n"); cout<<endl; memset(v,0,sizeof(v)); memset(a,0,sizeof(a)); ans=0; } return 0;}
0 0
- hdu 1829
- hdu 1829
- hdu 1829
- HDU 1829
- hdu 1829
- HDU 1829
- HDU-1829
- HDU 1829
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- 菜鸟理财——高级理财概念
- maven 修改使用的jkd版
- Android-解析json
- HDU-1272
- 二叉树
- HDU-1829
- java 线程池
- Python基础---习题
- POJ-1068
- Mac环境下的React-Native环境配置流程(主要解决问题Could not install the app on the device)
- 二叉树的最大深度与最小深度
- POJ-1321
- mysql 如何将一个数据库中某个表中某个字段导入另外一个数据库里指定表里
- Properties工具类获取配置文件数据