日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

bzoj1116 [POI2008]CLO

發布時間:2025/5/22 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bzoj1116 [POI2008]CLO 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接

畫畫圖發現如果某一個連通塊中沒有環那么就不可能存在方案

所以直接并查集維護一個連通塊中有沒有環

1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<string> 7 #include<cmath> 8 #include<ctime> 9 #include<queue> 10 #include<stack> 11 #include<map> 12 #include<set> 13 #define rre(i,r,l) for(int i=(r);i>=(l);i--) 14 #define re(i,l,r) for(int i=(l);i<=(r);i++) 15 #define Clear(a,b) memset(a,b,sizeof(a)) 16 #define inout(x) printf("%d",(x)) 17 #define douin(x) scanf("%lf",&x) 18 #define strin(x) scanf("%s",(x)) 19 #define LLin(x) scanf("%lld",&x) 20 #define op operator 21 #define CSC main 22 typedef unsigned long long ULL; 23 typedef const int cint; 24 typedef long long LL; 25 using namespace std; 26 void inin(int &ret) 27 { 28 ret=0;int f=0;char ch=getchar(); 29 while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();} 30 while(ch>='0'&&ch<='9')ret*=10,ret+=ch-'0',ch=getchar(); 31 ret=f?-ret:ret; 32 } 33 int fa[100010],bo[100010],n,m; 34 int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);} 35 int CSC() 36 { 37 inin(n),inin(m); 38 re(i,1,n)fa[i]=i; 39 re(i,1,m) 40 { 41 int x,y; 42 inin(x),inin(y); 43 int q=find(x),w=find(y); 44 if(q==w)bo[q]=1; 45 else fa[q]=w,bo[w]=bo[q]+bo[w]; 46 } 47 re(i,1,n)if(!bo[find(i)]){printf("NIE");return 0;} 48 printf("TAK"); 49 return 0; 50 }

?

轉載于:https://www.cnblogs.com/HugeGun/p/5182252.html

總結

以上是生活随笔為你收集整理的bzoj1116 [POI2008]CLO的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。