Pagini recente » Cod sursa (job #367292) | Cod sursa (job #400436) | Cod sursa (job #1865608) | Cod sursa (job #167177) | Cod sursa (job #527082)
Cod sursa(job #527082)
#include <fstream>
#define nmax 100002
using namespace std;
ifstream in("disjoint.in");
ofstream out("disjoint.out");
int T[nmax];
inline int multime(int nod)
{
while(T[nod])
nod=T[nod];
return nod;
}
int main()
{
int N,M,x,y,op;
in>>N>>M;
while(M--)
{
in>>op>>x>>y;
if(op==1)
T[x]=y;
else
if(multime(x)!=multime(y))
out<<"NU\n";
else out<<"DA\n";
}
return 0;
}