#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;
cin >> a >> b;
if(c[a][b] == 1) cout << "DA\n";
else cout << "NE\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
6736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1100 KB |
Output is correct |
2 |
Correct |
2 ms |
1100 KB |
Output is correct |
3 |
Correct |
18 ms |
1052 KB |
Output is correct |
4 |
Correct |
11 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
3 ms |
1100 KB |
Output is correct |
7 |
Correct |
18 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
6 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1100 KB |
Output is correct |
2 |
Correct |
2 ms |
1100 KB |
Output is correct |
3 |
Correct |
18 ms |
1052 KB |
Output is correct |
4 |
Correct |
11 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
3 ms |
1100 KB |
Output is correct |
7 |
Correct |
18 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
6 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
2 ms |
1100 KB |
Output is correct |
13 |
Correct |
23 ms |
1036 KB |
Output is correct |
14 |
Correct |
9 ms |
1016 KB |
Output is correct |
15 |
Correct |
1 ms |
1100 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
19 ms |
1096 KB |
Output is correct |
18 |
Correct |
2 ms |
1100 KB |
Output is correct |
19 |
Correct |
5 ms |
1100 KB |
Output is correct |
20 |
Correct |
3 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
6736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |