| 比赛 | 20120712 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 爆炸化合物 | 最终得分 | 100 |
| 用户昵称 | 安呐一条小咸鱼。 | 运行时间 | 0.108 s |
| 代码语言 | C++ | 内存使用 | 0.67 MiB |
| 提交时间 | 2016-02-17 08:07:56 | ||
#include<cstdio>
int f[100001];
int x,y;
int tot=0;
inline int find(int x){
if(f[x]==x) return x;
return f[x]=find( f[x] );
}
int main()
{
freopen("explosion.in","r",stdin);
freopen("explosion.out","w",stdout);
for(int i=1;i<=90000;i++)f[i]=i;
while(scanf("%d%d",&x,&y)==2)
{
x++;
y++;
x=find(x);
y=find(y);
if(x!=y)f[x]=y;
else tot++;
}
printf("%d\n",tot);
}