#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
int n, m, q, reachable[N][N];
vector<int> g[N];
void dfs(int v, int s){
reachable[s][v] = 1;
for (int u : g[v])
if (!reachable[s][u])
dfs(u, s);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
for (int j = 0; j < m; j ++){
for (int i = 1; i <= n; i ++){
int x;
cin >> x;
g[i].push_back(x);
}
}
for (int v = 1; v <= n; v ++)
dfs(v, v);
for (int i = 0; i < q; i ++){
int u, v;
cin >> u >> v;
if (reachable[u][v])
cout << "DA\n";
else
cout << "NE\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
5972 KB |
Output is correct |
2 |
Correct |
60 ms |
5408 KB |
Output is correct |
3 |
Correct |
55 ms |
5216 KB |
Output is correct |
4 |
Correct |
80 ms |
5728 KB |
Output is correct |
5 |
Correct |
57 ms |
5712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
1 ms |
2540 KB |
Output is correct |
17 |
Correct |
2 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2688 KB |
Output is correct |
20 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
5972 KB |
Output is correct |
2 |
Correct |
60 ms |
5408 KB |
Output is correct |
3 |
Correct |
55 ms |
5216 KB |
Output is correct |
4 |
Correct |
80 ms |
5728 KB |
Output is correct |
5 |
Correct |
57 ms |
5712 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
1 ms |
2648 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2540 KB |
Output is correct |
22 |
Correct |
2 ms |
2652 KB |
Output is correct |
23 |
Correct |
1 ms |
2652 KB |
Output is correct |
24 |
Correct |
1 ms |
2688 KB |
Output is correct |
25 |
Correct |
1 ms |
2648 KB |
Output is correct |
26 |
Correct |
186 ms |
9848 KB |
Output is correct |
27 |
Correct |
108 ms |
9812 KB |
Output is correct |
28 |
Correct |
690 ms |
8840 KB |
Output is correct |
29 |
Correct |
464 ms |
9604 KB |
Output is correct |
30 |
Correct |
96 ms |
8784 KB |
Output is correct |
31 |
Correct |
126 ms |
8768 KB |
Output is correct |
32 |
Correct |
862 ms |
9808 KB |
Output is correct |
33 |
Correct |
136 ms |
9916 KB |
Output is correct |
34 |
Correct |
187 ms |
9812 KB |
Output is correct |
35 |
Correct |
111 ms |
10064 KB |
Output is correct |