#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long int
#define oo 1e18 + 5
#define pii pair<int, int>
const int MAX = 105;
bool visited[MAX];
set<int> g[MAX];
bool accessible[MAX][MAX];
void dfs(int node, vector<int> path){
visited[node] = true;
path.push_back(node);
for(int a : path){
accessible[a][node] = true;
accessible[node][a] = true;
}
for(int to : g[node]){
if(!visited[to]){
dfs(to, path);
}
}
}
int main(){
int n, m, q; cin >> n >> m >> q;
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
int a; cin >> a;
g[j].insert(a);
g[a].insert(j);
}
}
for (int i = 1; i <= n; i++)
{
if(!visited[i]){
dfs(i, vector<int>());
}
}
while(q--){
int a, b; cin >> a >> b;
if(accessible[a][b]){
cout << "DA\n";
}
else{
cout << "NE\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
316 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
724 KB |
Output is correct |
4 |
Correct |
4 ms |
572 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
836 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
724 KB |
Output is correct |
4 |
Correct |
4 ms |
572 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
836 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
324 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
4 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
5 ms |
852 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
316 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |