# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
534730 |
2022-03-08T17:26:58 Z |
kappa |
Kutije (COCI21_kutije) |
C++14 |
|
1000 ms |
9408 KB |
#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
struct node{
long long parent;
long long rank;
};
node v[200005];
long long find(long long u){
if(u != v[u].parent){
v[u].parent = find(v[u].parent);
}
return v[u].parent;
}
void merge(long long x, long long y){
long long px = find(x);
long long py = find(y);
if(v[px].rank > v[py].rank){
v[py].parent = px;
}else{
v[px].parent = py;
}
if(v[px].rank == v[py].rank){
v[py].rank++;
}
}
int main(){
cin >> n >> m >> q;
for (int i = 1; i <= n; ++i)
{
v[i].parent = i;
v[i].rank = 0;
}
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= n; ++j)
{
int t;
cin >> t;
merge(t, j);
}
}
while(q--){
int l, r;
cin >> l >> r;
if(find(l) == find(r)){
cout << "DA\n";
}
else{
cout << "NE\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
799 ms |
1996 KB |
Output is correct |
2 |
Correct |
723 ms |
1864 KB |
Output is correct |
3 |
Correct |
686 ms |
1732 KB |
Output is correct |
4 |
Correct |
813 ms |
1992 KB |
Output is correct |
5 |
Correct |
800 ms |
1952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
316 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
312 KB |
Output is correct |
7 |
Correct |
4 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
312 KB |
Output is correct |
10 |
Correct |
3 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
316 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
312 KB |
Output is correct |
7 |
Correct |
4 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
312 KB |
Output is correct |
10 |
Correct |
3 ms |
308 KB |
Output is correct |
11 |
Correct |
2 ms |
324 KB |
Output is correct |
12 |
Correct |
3 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
320 KB |
Output is correct |
14 |
Correct |
2 ms |
204 KB |
Output is correct |
15 |
Correct |
2 ms |
204 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
312 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
799 ms |
1996 KB |
Output is correct |
2 |
Correct |
723 ms |
1864 KB |
Output is correct |
3 |
Correct |
686 ms |
1732 KB |
Output is correct |
4 |
Correct |
813 ms |
1992 KB |
Output is correct |
5 |
Correct |
800 ms |
1952 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
3 ms |
316 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
312 KB |
Output is correct |
12 |
Correct |
4 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
312 KB |
Output is correct |
15 |
Correct |
3 ms |
308 KB |
Output is correct |
16 |
Correct |
2 ms |
324 KB |
Output is correct |
17 |
Correct |
3 ms |
204 KB |
Output is correct |
18 |
Correct |
2 ms |
320 KB |
Output is correct |
19 |
Correct |
2 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
204 KB |
Output is correct |
24 |
Correct |
2 ms |
312 KB |
Output is correct |
25 |
Correct |
3 ms |
204 KB |
Output is correct |
26 |
Correct |
977 ms |
5700 KB |
Output is correct |
27 |
Correct |
970 ms |
9408 KB |
Output is correct |
28 |
Correct |
797 ms |
7840 KB |
Output is correct |
29 |
Correct |
954 ms |
8996 KB |
Output is correct |
30 |
Correct |
821 ms |
8004 KB |
Output is correct |
31 |
Correct |
813 ms |
8112 KB |
Output is correct |
32 |
Execution timed out |
1075 ms |
9352 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |