#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 |
1 |
Correct |
70 ms |
9684 KB |
Output is correct |
2 |
Correct |
76 ms |
8788 KB |
Output is correct |
3 |
Correct |
56 ms |
8236 KB |
Output is correct |
4 |
Correct |
69 ms |
9556 KB |
Output is correct |
5 |
Correct |
57 ms |
9556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
756 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
756 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
784 KB |
Output is correct |
16 |
Correct |
1 ms |
840 KB |
Output is correct |
17 |
Correct |
2 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
1 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
9684 KB |
Output is correct |
2 |
Correct |
76 ms |
8788 KB |
Output is correct |
3 |
Correct |
56 ms |
8236 KB |
Output is correct |
4 |
Correct |
69 ms |
9556 KB |
Output is correct |
5 |
Correct |
57 ms |
9556 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
756 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
1 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
784 KB |
Output is correct |
21 |
Correct |
1 ms |
840 KB |
Output is correct |
22 |
Correct |
2 ms |
852 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
1 ms |
860 KB |
Output is correct |
25 |
Correct |
1 ms |
860 KB |
Output is correct |
26 |
Correct |
172 ms |
17748 KB |
Output is correct |
27 |
Correct |
114 ms |
17920 KB |
Output is correct |
28 |
Correct |
575 ms |
15472 KB |
Output is correct |
29 |
Correct |
413 ms |
17476 KB |
Output is correct |
30 |
Correct |
94 ms |
15364 KB |
Output is correct |
31 |
Correct |
97 ms |
15732 KB |
Output is correct |
32 |
Correct |
729 ms |
17476 KB |
Output is correct |
33 |
Correct |
98 ms |
17468 KB |
Output is correct |
34 |
Correct |
176 ms |
17492 KB |
Output is correct |
35 |
Correct |
105 ms |
17824 KB |
Output is correct |