tjut 3478
来源:互联网 发布:数控编程怎么学 编辑:程序博客网 时间:2024/06/16 20:28
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int MAXN = 100010;const int MAXM = 500010;struct Edge{ int v, next;}edge[MAXM];int n, m, s;int cnt;int first[MAXN];bool color[MAXN], vis[MAXN];void init(){ cnt = 0; memset(vis, 0, sizeof(vis)); memset(color, 0, sizeof(color)); memset(first, -1, sizeof(first));}void read_graph(int u, int v){ edge[cnt].v = v; edge[cnt].next = first[u], first[u] = cnt++;}int find(int u){ for(int e = first[u]; e != -1; e = edge[e].next) { int v = edge[e].v; if(!vis[v]) { vis[v] = 1; color[v] = !color[u]; find(v); } else if(color[u] == color[v]) return false; } return true;}int main(){ int T, times = 0; scanf("%d", &T); while(T--) { init(); scanf("%d%d%d", &n, &m, &s); while(m--) { int u, v; scanf("%d%d", &u, &v); read_graph(u, v); read_graph(v, u); } printf("Case %d: ", ++times); color[s] = 1; vis[s] = 1; printf(find(s)?"NO\n":"YES\n"); } return 0;}
0 0
- tjut 3478
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- 第一篇博客
- 爬虫开源项目及其思想
- Fiddler (一) 教程
- python基础(5):深入理解 python 中的赋值、引用、拷贝、作用域
- 图像预处理-光照补偿
- tjut 3478
- 对数据库操作时,提示数据库打开失败
- Swaps in Permutation
- javamelody的简单使用[转]
- mtk6735 GPIO驱动
- cut的用法
- 制作Unity插件之-顶部菜单栏及右键菜单栏拓展
- 欢迎使用CSDN-markdown编辑器
- c++指针