# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102529 |
2024-10-18T08:31:31 Z |
EkinOnal |
Kutije (COCI21_kutije) |
C++17 |
|
128 ms |
1964 KB |
#pragma GCC optimize("O3,unroll-loops,Ofast")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
using namespace std;
const short N = 1000+2;
struct DSU {
vector<int> e;
DSU(){e.resize(N);for(short i = 1; i < N-1; i++) e[i]=-1;}
short get(short x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool sameSet(short a, short b) { return get(a) == get(b); }
short size(short x) { return -e[get(x)]; }
bool unite(short x, short y) { // union by size
x = get(x), y = get(y); if (x == y) return 0;
if (e[x] > e[y]) swap(x,y);
e[x] += e[y]; e[y] = x; return 1;
}
};
DSU t;
short n,m,a,b;
int q;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>q;
for(short i=1;i<=m;i++){
for(short j=1;j<=n;j++){
cin>>a;
t.unite(j,a);
}
}
while(q--){
cin>>a>>b;
if(t.sameSet(a,b)) cout<<"DA\n";
else cout<<"NE\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
1864 KB |
Output is correct |
2 |
Correct |
50 ms |
1608 KB |
Output is correct |
3 |
Correct |
44 ms |
1588 KB |
Output is correct |
4 |
Correct |
52 ms |
1864 KB |
Output is correct |
5 |
Correct |
57 ms |
1964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
508 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
1864 KB |
Output is correct |
2 |
Correct |
50 ms |
1608 KB |
Output is correct |
3 |
Correct |
44 ms |
1588 KB |
Output is correct |
4 |
Correct |
52 ms |
1864 KB |
Output is correct |
5 |
Correct |
57 ms |
1964 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
508 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
98 ms |
1888 KB |
Output is correct |
27 |
Correct |
96 ms |
1944 KB |
Output is correct |
28 |
Correct |
91 ms |
1476 KB |
Output is correct |
29 |
Correct |
90 ms |
1864 KB |
Output is correct |
30 |
Correct |
86 ms |
1484 KB |
Output is correct |
31 |
Correct |
85 ms |
1476 KB |
Output is correct |
32 |
Correct |
94 ms |
1744 KB |
Output is correct |
33 |
Correct |
107 ms |
1864 KB |
Output is correct |
34 |
Correct |
93 ms |
1864 KB |
Output is correct |
35 |
Correct |
128 ms |
1864 KB |
Output is correct |