This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |