Submission #1022151

#TimeUsernameProblemLanguageResultExecution timeMemory
1022151UmairAhmadMirzaKutije (COCI21_kutije)C++17
70 / 70
830 ms23636 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=2e5+5; int const mod=1e9+7; vector<int> adj[N]; int com[N],c=0; void dfs(int node){ com[node]=c; for(int i:adj[node]) if(com[i]==0) dfs(i); } int main(){ int n,m,q; cin>>n>>m>>q; while(m--){ for(int i=1;i<=n;i++){ int p; cin>>p; adj[p].push_back(i); adj[i].push_back(p); } } for (int i = 1; i <=n; ++i) if(com[i]==0){ c++; dfs(i); } while(q--){ int u,v; cin>>u>>v; if(com[u]==com[v]) cout<<"DA"<<endl; else cout<<"NE"<<endl; } 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...