Pagini recente » Cod sursa (job #3197171) | Cod sursa (job #2313674) | Cod sursa (job #1340608) | Cod sursa (job #258155) | Cod sursa (job #588964)
Cod sursa(job #588964)
#include <stdio.h>
#include <fstream>
#define nmax 100042
using namespace std;
int f[nmax];
inline int multime(int nod)
{
while(f[nod])
nod=f[nod];
return nod;
}
void pad()
{
int n,t,x,y,op,m1,m2;
scanf("%d%d",&n,&t);
while(t--)
{
scanf("%d%d%d",&op,&x,&y);
m1=multime(x);
m2=multime(y);
if(op==1)
f[m1]=m2;
else
if(m1==m2)
printf("DA\n");
else
printf("NU\n");
}
}
int main()
{
freopen("disjoint.in","r",stdin);
freopen("disjoint.out","w",stdout);
pad();
return 0;
}