# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102452 | 2024-10-18T07:24:16 Z | yavuzskarahan | Kutije (COCI21_kutije) | C++14 | 0 ms | 0 KB |
// In the name of God, the Most Gracious, the Most Merciful. // iflbot(); - @yavuzskarahan #include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0); cin.tie(0); #define FOR(i, L, R) for (int i = (L); i <= (R); i++) #define pb push_back int n, m, q, a, b, u, v; vector<int> adj[1002]; int parent[1002]; inline int find(int a){ if (a==parent[a]) return a; else return parent[a] = find(parent[a]); } inline void unite(int a, int b){ a = find(a); b = find(b); parent[b] = a; return; } inline int solve(){ cin >> n >> m >> q; FOR(i,1,n) parent[i] = i; FOR(i,1,m){ FOR(j,1,n){ cin >> a; unite(j,a); } } while(q--){ FOR(i,0,n+1) visited[i] = false; cin >> a >> b; if (find(a) == find(b)) cout << "DA" << endl; else cout << "NE" << endl; } return 0; } int main() { fast; solve(); return 0; }