This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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... |