# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948460 |
2024-03-18T06:31:48 Z |
dimashhh |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
22868 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, MOD = 998244353;
int p[N],sz[N],n,m,q,d[N];
void reset(){
for(int i = 1;i <= n;i++){
sz[i] = 1;
p[i] = i;
d[i] = 0;
}
}
pair<int, int> get(int v) {
if(p[v] == v){
return {v,0};
}
pair<int,int> x = get(p[v]);
return {x.first,d[v]+x.second};
}
bool merge(int a,int b){
pair<int,int> x = get(a),y = get(b);
if(sz[x.first] < sz[y.first]){
swap(x,y);
}
a = x.first;
b = y.first;
if(a == b){
if(x.second % 2 == y.second % 2){
return false;
}
return true;
}
p[b] = a;
sz[a] += sz[b];
d[b] = (x.second % 2 == y.second % 2);
return true;
}
int x[N],y[N];
vector<pair<int,int>> qr[N];
vector<int> ids[N];
bool ans[N];
void test(){
cin >> n >> m >> q;
for(int i = 1;i <= m;i++){
cin >> x[i] >> y[i];
}
for(int i = 1;i <= q;i++){
int l,r;
cin >> l >> r;
qr[l].push_back({i,r});
}
for(int i = 1;i <= m;i++){
if(qr[i].size()){
reset();
}else continue;
for(int j = i;j <= m;j++){
ids[j].clear();
}
for(auto [id,j]:qr[i]){
ids[j].push_back(id);
}
bool is = true;
for(int j = 1;j < i;j++) {
is &= merge(x[j],y[j]);
}
for(int j = m;j >= i;j--){
for(int k:ids[j]){
ans[k] = (!is);
}
is &= merge(x[j],y[j]);
}
}
for(int i = 1;i <= q;i++){
cout << (ans[i] ? "YES\n":"NO\n");
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int T = 1;
// cin >> T;
while(T--){
test();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
3 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12632 KB |
Output is correct |
8 |
Correct |
3 ms |
12636 KB |
Output is correct |
9 |
Correct |
3 ms |
12636 KB |
Output is correct |
10 |
Correct |
3 ms |
12636 KB |
Output is correct |
11 |
Correct |
3 ms |
12636 KB |
Output is correct |
12 |
Correct |
3 ms |
12636 KB |
Output is correct |
13 |
Correct |
3 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
12792 KB |
Output is correct |
15 |
Correct |
3 ms |
12636 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
3 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12636 KB |
Output is correct |
21 |
Correct |
3 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12632 KB |
Output is correct |
23 |
Correct |
3 ms |
12636 KB |
Output is correct |
24 |
Correct |
3 ms |
12636 KB |
Output is correct |
25 |
Correct |
3 ms |
12636 KB |
Output is correct |
26 |
Correct |
3 ms |
12636 KB |
Output is correct |
27 |
Correct |
3 ms |
12784 KB |
Output is correct |
28 |
Correct |
3 ms |
12636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
3 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12632 KB |
Output is correct |
8 |
Correct |
3 ms |
12636 KB |
Output is correct |
9 |
Correct |
3 ms |
12636 KB |
Output is correct |
10 |
Correct |
3 ms |
12636 KB |
Output is correct |
11 |
Correct |
3 ms |
12636 KB |
Output is correct |
12 |
Correct |
3 ms |
12636 KB |
Output is correct |
13 |
Correct |
3 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
12792 KB |
Output is correct |
15 |
Correct |
3 ms |
12636 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
3 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12636 KB |
Output is correct |
21 |
Correct |
3 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12632 KB |
Output is correct |
23 |
Correct |
3 ms |
12636 KB |
Output is correct |
24 |
Correct |
3 ms |
12636 KB |
Output is correct |
25 |
Correct |
3 ms |
12636 KB |
Output is correct |
26 |
Correct |
3 ms |
12636 KB |
Output is correct |
27 |
Correct |
3 ms |
12784 KB |
Output is correct |
28 |
Correct |
3 ms |
12636 KB |
Output is correct |
29 |
Correct |
9 ms |
12632 KB |
Output is correct |
30 |
Correct |
23 ms |
12636 KB |
Output is correct |
31 |
Correct |
30 ms |
12992 KB |
Output is correct |
32 |
Correct |
28 ms |
12636 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
28 ms |
12632 KB |
Output is correct |
35 |
Correct |
28 ms |
12632 KB |
Output is correct |
36 |
Correct |
20 ms |
12836 KB |
Output is correct |
37 |
Correct |
22 ms |
12884 KB |
Output is correct |
38 |
Correct |
22 ms |
12888 KB |
Output is correct |
39 |
Correct |
22 ms |
12636 KB |
Output is correct |
40 |
Correct |
25 ms |
12636 KB |
Output is correct |
41 |
Correct |
27 ms |
12632 KB |
Output is correct |
42 |
Correct |
24 ms |
12636 KB |
Output is correct |
43 |
Correct |
28 ms |
12884 KB |
Output is correct |
44 |
Correct |
28 ms |
12880 KB |
Output is correct |
45 |
Correct |
30 ms |
12884 KB |
Output is correct |
46 |
Correct |
27 ms |
12892 KB |
Output is correct |
47 |
Correct |
23 ms |
12632 KB |
Output is correct |
48 |
Correct |
27 ms |
12636 KB |
Output is correct |
49 |
Correct |
25 ms |
12860 KB |
Output is correct |
50 |
Correct |
25 ms |
12636 KB |
Output is correct |
51 |
Correct |
28 ms |
12636 KB |
Output is correct |
52 |
Correct |
29 ms |
12632 KB |
Output is correct |
53 |
Correct |
28 ms |
12888 KB |
Output is correct |
54 |
Correct |
27 ms |
12892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
62 ms |
22808 KB |
Output is correct |
4 |
Correct |
68 ms |
21708 KB |
Output is correct |
5 |
Correct |
66 ms |
22308 KB |
Output is correct |
6 |
Correct |
61 ms |
21576 KB |
Output is correct |
7 |
Correct |
63 ms |
21560 KB |
Output is correct |
8 |
Correct |
62 ms |
20936 KB |
Output is correct |
9 |
Correct |
64 ms |
21192 KB |
Output is correct |
10 |
Correct |
69 ms |
21964 KB |
Output is correct |
11 |
Correct |
62 ms |
21580 KB |
Output is correct |
12 |
Correct |
63 ms |
22132 KB |
Output is correct |
13 |
Correct |
62 ms |
21196 KB |
Output is correct |
14 |
Correct |
62 ms |
21444 KB |
Output is correct |
15 |
Correct |
63 ms |
21704 KB |
Output is correct |
16 |
Correct |
75 ms |
22376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
3 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12632 KB |
Output is correct |
8 |
Correct |
3 ms |
12636 KB |
Output is correct |
9 |
Correct |
3 ms |
12636 KB |
Output is correct |
10 |
Correct |
3 ms |
12636 KB |
Output is correct |
11 |
Correct |
3 ms |
12636 KB |
Output is correct |
12 |
Correct |
3 ms |
12636 KB |
Output is correct |
13 |
Correct |
3 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
12792 KB |
Output is correct |
15 |
Correct |
3 ms |
12636 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
3 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12636 KB |
Output is correct |
21 |
Correct |
3 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12632 KB |
Output is correct |
23 |
Correct |
3 ms |
12636 KB |
Output is correct |
24 |
Correct |
3 ms |
12636 KB |
Output is correct |
25 |
Correct |
3 ms |
12636 KB |
Output is correct |
26 |
Correct |
3 ms |
12636 KB |
Output is correct |
27 |
Correct |
3 ms |
12784 KB |
Output is correct |
28 |
Correct |
3 ms |
12636 KB |
Output is correct |
29 |
Correct |
62 ms |
22808 KB |
Output is correct |
30 |
Correct |
68 ms |
21708 KB |
Output is correct |
31 |
Correct |
66 ms |
22308 KB |
Output is correct |
32 |
Correct |
61 ms |
21576 KB |
Output is correct |
33 |
Correct |
63 ms |
21560 KB |
Output is correct |
34 |
Correct |
62 ms |
20936 KB |
Output is correct |
35 |
Correct |
64 ms |
21192 KB |
Output is correct |
36 |
Correct |
69 ms |
21964 KB |
Output is correct |
37 |
Correct |
62 ms |
21580 KB |
Output is correct |
38 |
Correct |
63 ms |
22132 KB |
Output is correct |
39 |
Correct |
62 ms |
21196 KB |
Output is correct |
40 |
Correct |
62 ms |
21444 KB |
Output is correct |
41 |
Correct |
63 ms |
21704 KB |
Output is correct |
42 |
Correct |
75 ms |
22376 KB |
Output is correct |
43 |
Correct |
699 ms |
22828 KB |
Output is correct |
44 |
Correct |
867 ms |
22768 KB |
Output is correct |
45 |
Correct |
917 ms |
22248 KB |
Output is correct |
46 |
Correct |
904 ms |
21812 KB |
Output is correct |
47 |
Correct |
1186 ms |
21772 KB |
Output is correct |
48 |
Correct |
1370 ms |
22100 KB |
Output is correct |
49 |
Correct |
1294 ms |
22836 KB |
Output is correct |
50 |
Correct |
1091 ms |
21636 KB |
Output is correct |
51 |
Correct |
1040 ms |
21908 KB |
Output is correct |
52 |
Correct |
1020 ms |
22868 KB |
Output is correct |
53 |
Correct |
1188 ms |
21072 KB |
Output is correct |
54 |
Correct |
1249 ms |
21488 KB |
Output is correct |
55 |
Correct |
1374 ms |
21976 KB |
Output is correct |
56 |
Correct |
1292 ms |
22364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
3 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12632 KB |
Output is correct |
8 |
Correct |
3 ms |
12636 KB |
Output is correct |
9 |
Correct |
3 ms |
12636 KB |
Output is correct |
10 |
Correct |
3 ms |
12636 KB |
Output is correct |
11 |
Correct |
3 ms |
12636 KB |
Output is correct |
12 |
Correct |
3 ms |
12636 KB |
Output is correct |
13 |
Correct |
3 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
12792 KB |
Output is correct |
15 |
Correct |
3 ms |
12636 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
3 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12636 KB |
Output is correct |
21 |
Correct |
3 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12632 KB |
Output is correct |
23 |
Correct |
3 ms |
12636 KB |
Output is correct |
24 |
Correct |
3 ms |
12636 KB |
Output is correct |
25 |
Correct |
3 ms |
12636 KB |
Output is correct |
26 |
Correct |
3 ms |
12636 KB |
Output is correct |
27 |
Correct |
3 ms |
12784 KB |
Output is correct |
28 |
Correct |
3 ms |
12636 KB |
Output is correct |
29 |
Correct |
9 ms |
12632 KB |
Output is correct |
30 |
Correct |
23 ms |
12636 KB |
Output is correct |
31 |
Correct |
30 ms |
12992 KB |
Output is correct |
32 |
Correct |
28 ms |
12636 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
28 ms |
12632 KB |
Output is correct |
35 |
Correct |
28 ms |
12632 KB |
Output is correct |
36 |
Correct |
20 ms |
12836 KB |
Output is correct |
37 |
Correct |
22 ms |
12884 KB |
Output is correct |
38 |
Correct |
22 ms |
12888 KB |
Output is correct |
39 |
Correct |
22 ms |
12636 KB |
Output is correct |
40 |
Correct |
25 ms |
12636 KB |
Output is correct |
41 |
Correct |
27 ms |
12632 KB |
Output is correct |
42 |
Correct |
24 ms |
12636 KB |
Output is correct |
43 |
Correct |
28 ms |
12884 KB |
Output is correct |
44 |
Correct |
28 ms |
12880 KB |
Output is correct |
45 |
Correct |
30 ms |
12884 KB |
Output is correct |
46 |
Correct |
27 ms |
12892 KB |
Output is correct |
47 |
Correct |
23 ms |
12632 KB |
Output is correct |
48 |
Correct |
27 ms |
12636 KB |
Output is correct |
49 |
Correct |
25 ms |
12860 KB |
Output is correct |
50 |
Correct |
25 ms |
12636 KB |
Output is correct |
51 |
Correct |
28 ms |
12636 KB |
Output is correct |
52 |
Correct |
29 ms |
12632 KB |
Output is correct |
53 |
Correct |
28 ms |
12888 KB |
Output is correct |
54 |
Correct |
27 ms |
12892 KB |
Output is correct |
55 |
Execution timed out |
2012 ms |
15544 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
3 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
3 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12632 KB |
Output is correct |
8 |
Correct |
3 ms |
12636 KB |
Output is correct |
9 |
Correct |
3 ms |
12636 KB |
Output is correct |
10 |
Correct |
3 ms |
12636 KB |
Output is correct |
11 |
Correct |
3 ms |
12636 KB |
Output is correct |
12 |
Correct |
3 ms |
12636 KB |
Output is correct |
13 |
Correct |
3 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
12792 KB |
Output is correct |
15 |
Correct |
3 ms |
12636 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
3 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12636 KB |
Output is correct |
21 |
Correct |
3 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12632 KB |
Output is correct |
23 |
Correct |
3 ms |
12636 KB |
Output is correct |
24 |
Correct |
3 ms |
12636 KB |
Output is correct |
25 |
Correct |
3 ms |
12636 KB |
Output is correct |
26 |
Correct |
3 ms |
12636 KB |
Output is correct |
27 |
Correct |
3 ms |
12784 KB |
Output is correct |
28 |
Correct |
3 ms |
12636 KB |
Output is correct |
29 |
Correct |
9 ms |
12632 KB |
Output is correct |
30 |
Correct |
23 ms |
12636 KB |
Output is correct |
31 |
Correct |
30 ms |
12992 KB |
Output is correct |
32 |
Correct |
28 ms |
12636 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
28 ms |
12632 KB |
Output is correct |
35 |
Correct |
28 ms |
12632 KB |
Output is correct |
36 |
Correct |
20 ms |
12836 KB |
Output is correct |
37 |
Correct |
22 ms |
12884 KB |
Output is correct |
38 |
Correct |
22 ms |
12888 KB |
Output is correct |
39 |
Correct |
22 ms |
12636 KB |
Output is correct |
40 |
Correct |
25 ms |
12636 KB |
Output is correct |
41 |
Correct |
27 ms |
12632 KB |
Output is correct |
42 |
Correct |
24 ms |
12636 KB |
Output is correct |
43 |
Correct |
28 ms |
12884 KB |
Output is correct |
44 |
Correct |
28 ms |
12880 KB |
Output is correct |
45 |
Correct |
30 ms |
12884 KB |
Output is correct |
46 |
Correct |
27 ms |
12892 KB |
Output is correct |
47 |
Correct |
23 ms |
12632 KB |
Output is correct |
48 |
Correct |
27 ms |
12636 KB |
Output is correct |
49 |
Correct |
25 ms |
12860 KB |
Output is correct |
50 |
Correct |
25 ms |
12636 KB |
Output is correct |
51 |
Correct |
28 ms |
12636 KB |
Output is correct |
52 |
Correct |
29 ms |
12632 KB |
Output is correct |
53 |
Correct |
28 ms |
12888 KB |
Output is correct |
54 |
Correct |
27 ms |
12892 KB |
Output is correct |
55 |
Correct |
62 ms |
22808 KB |
Output is correct |
56 |
Correct |
68 ms |
21708 KB |
Output is correct |
57 |
Correct |
66 ms |
22308 KB |
Output is correct |
58 |
Correct |
61 ms |
21576 KB |
Output is correct |
59 |
Correct |
63 ms |
21560 KB |
Output is correct |
60 |
Correct |
62 ms |
20936 KB |
Output is correct |
61 |
Correct |
64 ms |
21192 KB |
Output is correct |
62 |
Correct |
69 ms |
21964 KB |
Output is correct |
63 |
Correct |
62 ms |
21580 KB |
Output is correct |
64 |
Correct |
63 ms |
22132 KB |
Output is correct |
65 |
Correct |
62 ms |
21196 KB |
Output is correct |
66 |
Correct |
62 ms |
21444 KB |
Output is correct |
67 |
Correct |
63 ms |
21704 KB |
Output is correct |
68 |
Correct |
75 ms |
22376 KB |
Output is correct |
69 |
Correct |
699 ms |
22828 KB |
Output is correct |
70 |
Correct |
867 ms |
22768 KB |
Output is correct |
71 |
Correct |
917 ms |
22248 KB |
Output is correct |
72 |
Correct |
904 ms |
21812 KB |
Output is correct |
73 |
Correct |
1186 ms |
21772 KB |
Output is correct |
74 |
Correct |
1370 ms |
22100 KB |
Output is correct |
75 |
Correct |
1294 ms |
22836 KB |
Output is correct |
76 |
Correct |
1091 ms |
21636 KB |
Output is correct |
77 |
Correct |
1040 ms |
21908 KB |
Output is correct |
78 |
Correct |
1020 ms |
22868 KB |
Output is correct |
79 |
Correct |
1188 ms |
21072 KB |
Output is correct |
80 |
Correct |
1249 ms |
21488 KB |
Output is correct |
81 |
Correct |
1374 ms |
21976 KB |
Output is correct |
82 |
Correct |
1292 ms |
22364 KB |
Output is correct |
83 |
Execution timed out |
2012 ms |
15544 KB |
Time limit exceeded |
84 |
Halted |
0 ms |
0 KB |
- |