#include <bits/stdc++.h>
using namespace std;
#define MAXN 1020
#define INF 999999999
#define ll long long
#define F first
#define S second
#define endl "\n"
int n, m, q, lista[MAXN][MAXN], c[MAXN][MAXN];
bool foi[MAXN];
void dfs(int x){
for(int i = 1; i < MAXN; i++){
if(lista[x][i] == 1 && !foi[i]){
foi[i] = true;
dfs(i);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m >> q;
for(int i = 0; i < m; i++){
for(int j = 1; j <= n; j++){
int x;
cin >> x;
lista[j][x] = 1;
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++) foi[j] = false;
foi[i] = true;
dfs(i);
for(int j = 1; j <= n; j++){
if(foi[j]){
c[i][j] = 1;
}
}
}
for(int i = 0; i < q; i++){
int a, b;
for(int j = 0; j < MAXN; j++) foi[j] = false;
cin >> a >> b;
foi[a] = true;
dfs(a);
if(c[a][b] == 1) cout << "DA\n";
else cout << "NE\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1039 ms |
6684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1100 KB |
Output is correct |
2 |
Correct |
3 ms |
1100 KB |
Output is correct |
3 |
Correct |
34 ms |
972 KB |
Output is correct |
4 |
Correct |
19 ms |
1040 KB |
Output is correct |
5 |
Correct |
2 ms |
1100 KB |
Output is correct |
6 |
Correct |
5 ms |
1100 KB |
Output is correct |
7 |
Correct |
37 ms |
1040 KB |
Output is correct |
8 |
Correct |
2 ms |
1100 KB |
Output is correct |
9 |
Correct |
10 ms |
1156 KB |
Output is correct |
10 |
Correct |
4 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1100 KB |
Output is correct |
2 |
Correct |
3 ms |
1100 KB |
Output is correct |
3 |
Correct |
34 ms |
972 KB |
Output is correct |
4 |
Correct |
19 ms |
1040 KB |
Output is correct |
5 |
Correct |
2 ms |
1100 KB |
Output is correct |
6 |
Correct |
5 ms |
1100 KB |
Output is correct |
7 |
Correct |
37 ms |
1040 KB |
Output is correct |
8 |
Correct |
2 ms |
1100 KB |
Output is correct |
9 |
Correct |
10 ms |
1156 KB |
Output is correct |
10 |
Correct |
4 ms |
1100 KB |
Output is correct |
11 |
Correct |
7 ms |
1160 KB |
Output is correct |
12 |
Correct |
3 ms |
1100 KB |
Output is correct |
13 |
Correct |
41 ms |
984 KB |
Output is correct |
14 |
Correct |
18 ms |
1052 KB |
Output is correct |
15 |
Correct |
2 ms |
1100 KB |
Output is correct |
16 |
Correct |
4 ms |
972 KB |
Output is correct |
17 |
Correct |
36 ms |
1044 KB |
Output is correct |
18 |
Correct |
2 ms |
1100 KB |
Output is correct |
19 |
Correct |
9 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1039 ms |
6684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |