Submission #638539

#TimeUsernameProblemLanguageResultExecution timeMemory
638539NotLinuxKutije (COCI21_kutije)C++14
70 / 70
819 ms9492 KiB
/** * author: NotLinux * created: 06.09.2022 ~ 13:48:17 **/ #include <bits/stdc++.h> using namespace std; #define int long long #ifdef LOCAL #include "/home/notlinux/debug.h" #else #define debug(x...) void(37) #endif vector < int > par; int find(int a){ if(par[a] == a)return a; par[a] = find(par[a]); return par[a]; } void merge(int a, int b){ par[find(a)] = find(b); } void solve(){ int n,m,q;cin >> n >> m >> q; par.resize(2*n); iota(par.begin(),par.end(),0LL); while(m--){ for(int i = 1;i<=n;i++){ int dummy;cin >> dummy; merge(dummy , i); } } while(q--){ int a,b;cin >> a >> b; cout << (find(a)==find(b)?"DA":"NE") << endl; } } int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(nullptr); int tt=1; //cin >> tt; while(tt--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...