Submission #744636

#TimeUsernameProblemLanguageResultExecution timeMemory
744636MohamedAhmed04Kutije (COCI21_kutije)C++14
35 / 70
1077 ms17884 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 vis[MAX][MAX] ; int src ; void dfs(int node) { vis[src][node] = 1 ; for(auto &child : adj[node]) { if(!vis[src][child]) 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) src = i , dfs(i) ; while(q--) { int x , y ; cin>>x>>y ; if(vis[x][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...