LA 3644 X-Plosives 并查集
来源:互联网 发布:显卡评测软件 编辑:程序博客网 时间:2024/04/29 05:54
题目:
https://icpcarchive.ecs.baylor.edu/external/36/3644.pdf
题意半天没读懂,
#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<climits>#include<queue>#include<vector>#include<map>#include<sstream>#include<set>#include<stack>#include<utility>#pragma comment(linker, "/STACK:102400000,102400000")#define PI 3.1415926535897932384626#define eps 1e-10#define sqr(x) ((x)*(x))#define FOR0(i,n) for(int i=0 ;i<(n) ;i++)#define FOR1(i,n) for(int i=1 ;i<=(n) ;i++)#define FORD(i,n) for(int i=(n) ;i>=0 ;i--)#define lson num<<1,le,mid#define rson num<<1|1,mid+1,ri#define MID int mid=(le+ri)>>1#define zero(x)((x>0? x:-x)<1e-15)#define mk make_pair#define _f first#define _s secondusing namespace std;//const int INF= ;typedef long long ll;//const ll inf =1000000000000000;//1e15;//ifstream fin("input.txt");//ofstream fout("output.txt");//fin.close();//fout.close();//freopen("a.in","r",stdin);//freopen("a.out","w",stdout);const int INF =0x3f3f3f3f;const int maxn=100000+10 ;//const int maxm= ;//by yskysker123int pa,cnt,ans;int pre[maxn];int find(int x){ return x==pre[x]?x:find(pre[x]);}int main(){ int x,y; for(int i=0;i<=100000;i++) pre[i]=i; cnt=0,ans=0,pa=0; while(~scanf("%d",&x)) { if(x==-1) { printf("%d\n",ans); for(int i=0;i<=100000;i++) { pre[i]=i; } pa=0,cnt=0,ans=0; continue; } scanf("%d",&y); int r1=find(x); int r2=find(y); if(r1==r2) {ans++;continue;} else pre[r1]=r2; } return 0;}
0 0
- LA 3644 - X-Plosives,并查集
- LA 3644 X-Plosives / 并查集
- LA -3644 X-Plosives -并查集
- LA 3644 X-Plosives 并查集
- LA 3644 X-Plosives [并查集]
- X-Plosives(LA 3644)并查集
- LA 3644 X-Plosives [并查集]
- X-Plosives问题, LA 3644, 并查集算法
- UVALive(LA) 3644 X-Plosives (并查集)
- LA 3644 X-Plosives && LA 3027 Corporative Network (并查集入门)
- (DS 《算法竞赛入门经典》)LA 3644 X-Plosives(并查集)
- 初学并查集的例题1 X-Plosives,LA 3644
- UVALive 3644 X-Plosives 并查集
- UVALive - 3644 X-Plosives 并查集
- UVALive - 3644 X-Plosives 并查集
- LA - 3644 - X-Plosives
- LA 3644 X-Plosives
- LA 3644 X-Plosives
- ajax2用户名检测
- Jedis的简单封装,主要是去掉了类型。
- 我只想做一个平凡人
- ajax2.ajax
- Receiver
- LA 3644 X-Plosives 并查集
- 看板任务管理
- ajax2.guestbook.js
- AsyncTask源码解析
- iOS 开发:调试错误“Unable to run app in Simulator“
- 网址
- 欧锦赛球星谱:帕克领豪阵 诺天王对决加索尔
- 联系人Contacts
- ajax2.IndexController