标签:需要 href https pac 分享图片 using get load const
/*
* @Author: wxyww
* @Date: 2018-12-02 20:15:02
* @Last Modified time: 2018-12-02 20:21:40
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
using namespace std;
typedef long long ll;
const int N = 100000 + 100,M = 200000 + 100;
ll read() {
ll x=0,f=1;char c=getchar();
while(c<'0'||c>'9') {
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9') {
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
int col[N],fa[N];
int find(int x) {
return x == fa[x] ? x : fa[x] = find(fa[x]);
}
int main() {
int n = read(),m = read();
for(int i = 1;i <= n;++i) fa[i] = i;
for(int i = 1;i <= m;++i) {
int u = find(read()),v = find(read());
if(u == v) {
col[u] = 1;
continue;
}
if(rand() & 1) swap(u,v);
fa[u] = v;
col[v] |= col[u];
}
for(int i = 1;i <= n;++i) {
if(!col[find(i)]) {
puts("NIE");
return 0;
}
}
puts("TAK");
return 0;
}
标签:需要 href https pac 分享图片 using get load const
原文地址:https://www.cnblogs.com/wxyww/p/10055147.html