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;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
//#define int long long int
//#define ll long long
#define pb push_back
#define p push
#define f first
#define s second
#define N 1005
vector<int> adj[N];
int deg[N][N];
void dfs(int x,int ata){
if(deg[ata][x])return;
deg[ata][x]=1;
for(auto u:adj[x]){
if(deg[ata][u]==0)dfs(u,ata);
}
}
signed main(){
lalala;
int n,m,q;cin>>n>>m>>q;
for(int i=0;i<m;i++){
for(int i=1;i<=n;i++){
int x;cin>>x;
adj[x].pb(i);
}
}
for(int i=1;i<=n;i++){
dfs(i,i);
}
while(q--){
int a,b;cin>>a>>b;
if(deg[a][b])cout<<"DA"<<endl;
else cout<<"NE"<<endl;
}
}
# | 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... |