Submission #744637

#TimeUsernameProblemLanguageResultExecution timeMemory
744637MohamedAhmed04Kutije (COCI21_kutije)C++14
70 / 70
161 ms13832 KiB
#include <bits/stdc++.h> using namespace std ; const int MAX = 1000 + 10 ; int arr[MAX] ; int n , m , q ; vector< vector<int> >adj(MAX) ; int val[MAX] ; void dfs(int node) { for(auto &child : adj[node]) { if(!val[child]) val[child] = val[node] , dfs(child) ; } } int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>m>>q ; for(int i = 1 ; i <= m ; ++i) { for(int i = 1 ; i <= n ; ++i) { int x ; cin>>x ; adj[x].push_back(i) ; } } for(int i = 1 ; i <= n ; ++i) { if(val[i]) continue ; val[i] = i , dfs(i) ; } while(q--) { int x , y ; cin>>x>>y ; if(val[x] == val[y]) cout<<"DA\n" ; else cout<<"NE\n" ; } 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...