码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj2079[Poi2010]Guilds*

时间:2016-11-11 00:25:27      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:etc   put   uil   blank   tchar   否则   define   ret   targe   

bzoj2079[Poi2010]Guilds

题意:

给一个图染色,要求每个图必须染上某个色同时与另外一个色的点有边相连,问可否满足要求。n≤200000。

题解:

直接上结论:除非有点没有与别的点相连,否则肯定能满足要求。

代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <queue>
 5 #define inc(i,j,k) for(int i=j;i<=k;i++)
 6 #define maxn 200010
 7 using namespace std;
 8 
 9 inline int read(){
10     char ch=getchar(); int f=1,x=0;
11     while(ch<0||ch>9){if(ch==-)f=-1; ch=getchar();}
12     while(ch>=0&&ch<=9)x=x*10+ch-0,ch=getchar();
13     return f*x;
14 }
15 bool f[maxn]; int n,m;
16 int main(){
17     n=read(); m=read(); inc(i,1,m){int x=read(),y=read(); f[x]=f[y]=1;}
18     inc(i,1,n)if(!f[i]){puts("NIE"); goto end;} puts("TAK");
19     end: return 0;
20 }

 

20161107

bzoj2079[Poi2010]Guilds*

标签:etc   put   uil   blank   tchar   否则   define   ret   targe   

原文地址:http://www.cnblogs.com/YuanZiming/p/6052610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!