Pagini recente » Cod sursa (job #23393) | Cod sursa (job #1846652) | Cod sursa (job #751065) | Cod sursa (job #1932007) | Cod sursa (job #2682256)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
int n, m, op, x, y, fv[100005];
int main() {
fin >> n >> m;
for (int i = 1; i <= n; ++i)
fv[i] = i;
while (m--) {
fin >> op >> x >> y;
if (op == 1) {
for (int j = 1; j <= n; ++j)
if (j != y && fv[j] == fv[y])
fv[j] = fv[x];
fv[y] = fv[x];
}
else
fout << (fv[x] == fv[y] ? "DA\n" : "NU\n");
}
return 0;
}