Jigsaw_Killer @ 2017-10-22 12:25:17
评测后WA了三个点,全是too many or too few lines。大神帮看看。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
int pre[1000005],K,N,b,c,z;
using namespace std;
int mix(int x)
{
if(x!=pre[x])
return pre[x]=mix(pre[x]);
}
int jo(int x,int y)
{
int a=mix(x),b=mix(y);
if(a==b)
return 1;
pre[a]=b;
return 0;
}
int main ()
{
scanf("%d%d",&N,&K);
for(int a=0;a<=K;a++)
pre[a]=a;
for(int a=0;a<K;a++)
{
scanf("%d%d%d",&z,&b,&c);
if(z==1)
jo(b,c);
if(z==2)
if((mix(b))==(mix(c)))
printf("Y\n");
else
printf("N\n");
}
return 0;
}
by Jigsaw_Killer @ 2017-10-22 12:25:58
by CZQ_King @ 2018-07-12 15:21:47
蒟蒻路过
by 苏联大货司机 @ 2018-07-12 15:22:16
我来考古了
by BobHuang0724 @ 2018-07-12 15:23:37
by zhangyuxing @ 2018-07-12 15:23:40
考古祭
by d3NtMDAw @ 2018-07-12 15:24:40
前来考古