#include <bits/stdc++.h>
using namespace std;
vector <int> adj[1001];
bool vis[1001][1001];
void dfs (int pos, int k) {
vis[pos][k] = 1;
for (auto j : adj[pos]) {
if (!vis[j][k]) {
dfs(j, k);
}
}
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
int x;
cin >> x;
adj[j].push_back(x);
}
}
for (int i = 1; i <= n; i++) {
dfs(i, i);
}
while (q--) {
int a, b;
cin >> a >> b;
cout << (vis[a][b] ? "DA\n" : "NE\n");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
2900 KB |
Output is correct |
2 |
Correct |
58 ms |
2540 KB |
Output is correct |
3 |
Correct |
50 ms |
2388 KB |
Output is correct |
4 |
Correct |
68 ms |
2900 KB |
Output is correct |
5 |
Correct |
59 ms |
2948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
856 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
2900 KB |
Output is correct |
2 |
Correct |
58 ms |
2540 KB |
Output is correct |
3 |
Correct |
50 ms |
2388 KB |
Output is correct |
4 |
Correct |
68 ms |
2900 KB |
Output is correct |
5 |
Correct |
59 ms |
2948 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
2 ms |
852 KB |
Output is correct |
19 |
Correct |
1 ms |
856 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
205 ms |
6996 KB |
Output is correct |
27 |
Correct |
127 ms |
6884 KB |
Output is correct |
28 |
Correct |
849 ms |
8276 KB |
Output is correct |
29 |
Correct |
577 ms |
14156 KB |
Output is correct |
30 |
Correct |
97 ms |
12568 KB |
Output is correct |
31 |
Correct |
110 ms |
12624 KB |
Output is correct |
32 |
Execution timed out |
1022 ms |
9260 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |