Submission #1102453

#TimeUsernameProblemLanguageResultExecution timeMemory
1102453yavuzskarahanKutije (COCI21_kutije)C++14
70 / 70
787 ms2008 KiB
// 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--){ cin >> a >> b; if (find(a) == find(b)) cout << "DA" << endl; else cout << "NE" << endl; } return 0; } int main() { fast; solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...