#include<bits/stdc++.h>
using namespace std;
bool us[1005][1005];
set<int>g[1005];
int m, n, q;
void dfs(int v, int st)
{
us[st][v] = 1;
for(auto to : g[v])
{
if(!us[st][to])
dfs(to, st);
}
}
void fun()
{
cin>>m>>n>>q;
for(int i = 1; i <= n; i++)
{
for(int j = 1, a; j <= m; j++)
{
cin>>a;
g[a].insert(j);
}
}
for(int i = 1; i <= m; i++)
{
dfs(i, i);
}
for(int i = 1, a, b; i <= q; i++)
{
cin>>a>>b;
cout<<((us[a][b]) ? "DA" : "NE")<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ttt = 1;
//cin>>ttt;
while(ttt--)
fun();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
640 ms |
3104 KB |
Output is correct |
2 |
Correct |
578 ms |
2636 KB |
Output is correct |
3 |
Correct |
531 ms |
2548 KB |
Output is correct |
4 |
Correct |
676 ms |
2960 KB |
Output is correct |
5 |
Correct |
676 ms |
2772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
9 ms |
704 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
12 ms |
864 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
9 ms |
704 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
12 ms |
864 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
11 ms |
644 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
12 ms |
856 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
640 ms |
3104 KB |
Output is correct |
2 |
Correct |
578 ms |
2636 KB |
Output is correct |
3 |
Correct |
531 ms |
2548 KB |
Output is correct |
4 |
Correct |
676 ms |
2960 KB |
Output is correct |
5 |
Correct |
676 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
9 ms |
704 KB |
Output is correct |
9 |
Correct |
4 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
12 ms |
864 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
11 ms |
644 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
12 ms |
856 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
400 KB |
Output is correct |
26 |
Execution timed out |
1095 ms |
7108 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |