【BZOJ1116】[POI2008]CLO【BFS】
来源:互联网 发布:json与javascript 编辑:程序博客网 时间:2024/06/07 00:21
【题目链接】
同【这个题】
/* Pigonometry */#include <cstdio>#include <algorithm>using namespace std;const int maxn = 100005, maxm = 200005, maxq = maxn;int n, m, head[maxn], cnt, q[maxq];bool vis[maxn];struct _edge {int v, next;} g[maxm << 1];inline int iread() {int f = 1, x = 0; char ch = getchar();for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';return f * x;}inline void add(int u, int v) {g[cnt] = (_edge){v, head[u]};head[u] = cnt++;}inline bool bfs(int x) {int h = 0, t = 0, node = 0, edge = 0;vis[q[t++] = x] = 1;while(h != t) {int u = q[h++];node++;for(int i = head[u]; ~i; i = g[i].next) {edge++;if(!vis[g[i].v]) vis[q[t++] = g[i].v] = 1;}}return (edge >> 1) == node - 1;}int main() {n = iread(); m = iread();for(int i = 0; i <= n; i++) head[i] = -1; cnt = 0;for(int i = 1; i <= m; i++) {int u = iread(), v = iread();add(u, v); add(v, u);}bool ans = 0;for(int i = 1; i <= n; i++) if(!vis[i]) {ans = bfs(i);if(ans) break;}printf(ans ? "NIE\n" : "TAK\n");return 0;}
0 0
- 【BZOJ1116】[POI2008]CLO【BFS】
- bzoj1116 [POI2008]CLO
- bzoj1116: [POI2008]CLO
- BZOJ1116: [POI2008]CLO
- 【bzoj1116】 [POI2008]CLO
- bzoj1116 [POI2008]CLO
- BZOJ1116: [POI2008]CLO 并查集
- bzoj1116 [POI2008]CLO(记录带环连通块)
- POI2008 CLO
- BZOJ1116 CLO [并查集]
- 【BZOJ 1116】 [POI2008]CLO
- BZOJ 1116: [POI2008]CLO
- 1116: [POI2008]CLO|深度搜索
- BZOJ 1116: [POI2008]CLO BZOJ
- 1116: [POI2008]CLO (并查集)
- 【并查集】【bzoj 1116】: [POI2008]CLO
- BZOJ 1116 POI2008 CLO 并查集
- BZOJ 1116 [POI2008]CLO 并查集
- PHP基础整理4
- ORA-00439: feature not enabled: Real Application Clusters
- Java ConcurrentMap 源码分析
- 多线程
- 论指针与数组
- 【BZOJ1116】[POI2008]CLO【BFS】
- Hive(一个数据仓库)
- C# Socket异步通信demo,一个服务器对应多个客户端
- struts2中<s:select>标签的使用
- 浅析Motion Design
- MFC->字符的编码方式
- 视频编码解码学习之二:编解码框架
- java.util.concurrent.CountDownLatch
- Python中遇到"UnicodeDecodeError: ‘gbk’ codec can’t decode bytes in position 2-3: illegal multibyte sequ