Submission #579176

#TimeUsernameProblemLanguageResultExecution timeMemory
579176Trisanu_DasKutije (COCI21_kutije)C++17
35 / 70
1078 ms9412 KiB
#include <bits/stdc++.h> using namespace std; int par[1001]; int Find(int x) { if(x == par[x]) { return x; } return par[x] = Find(par[x]); } void Unite(int a, int b) { a = Find(a), b = Find(b); if(a == b) { return; } par[a] = b; } int main() { int n, m, q; cin >> n >> m >> q; for(int i = 1; i <= n; i++) { par[i] = i; } for(int i = 1; i <= m; i++) { for(int j = 1; j <= n; j++) { int x; cin >> x; if(Find(x) != Find(j)) { Unite(x, j); } } } for(int i = 1; i <= q; i++) { int a, b; cin >> a >> b; if(Find(a) != Find(b)) { cout << "NE\n"; } else { cout << "DA\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...