题目大意:无向图,把图上的点染成黑白色,要求黑色点要至少和一个白色点相连,白色点同理,求是否有解
题解:无解条件:存在联通块只有一个点。若联通块点数大于1,则按照二分图染色即可满足条件
我的收获:233
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int M=500005;
int n,m,x,y;
bool f[M];
void work()
{
for(int i=1;i<=n;i++)
if(!f[i]) {puts("NIE");return ;}
puts("TAK");
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
scanf("%d%d",&x,&y),f[x]=f[y]=1;
work();
return 0;
}