| 记录编号 | 130070 | 评测结果 | AAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 899.爆炸化合物 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.117 s | ||
| 提交时间 | 2014-10-21 19:12:53 | 内存使用 | 0.67 MiB | ||
#include<cstdio>
int f[100001];
int x,y;
int ans=0;
int find(int x){return f[x]?f[x]=find(f[x]):x;};
int main()
{
freopen("explosion.in", "r", stdin);
freopen("explosion.out", "w", stdout);
while(scanf("%d%d",&x,&y)==2)
{
x++;y++;
x=find(x);
y=find(y);
if(x!=y)f[x]=y;
else ans++;
}
printf("%d\n",ans);
}