# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
877325 |
2023-11-23T06:29:55 Z |
huutuan |
Joker (BOI20_joker) |
C++14 |
|
2000 ms |
13884 KB |
#include<bits/stdc++.h>
#define taskname "nohome"
using namespace std;
struct DSU{
vector<int> lab, val;
bool ans=1;
void init(int n){
lab.assign(n+1, -1);
val.assign(n+1, 0);
}
pair<int, int> find_set(int u){
if (lab[u]<0) return {u, 0};
auto p=find_set(lab[u]);
lab[u]=p.first;
val[u]^=p.second;
return {lab[u], val[u]};
}
void union_sets(int u, int v){
auto pu=find_set(u), pv=find_set(v);
if (pu.first!=pv.first){
if (lab[pu.first]>lab[pv.first]) swap(pu, pv), swap(u, v);
lab[pu.first]+=lab[pv.first];
val[pu.first]=0;
lab[pv.first]=pu.first;
val[pv.first]=pu.second^pv.second^1;
}else
ans&=pu.second^pv.second;
}
};
const int N=2e5+1;
int n, m, q, ans[N];
pair<int, int> edge[N];
vector<pair<int, int>> qq[N];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen(taskname".inp", "r", stdin);
// freopen(taskname".out", "w", stdout);
cin >> n >> m >> q;
bool sus=1;
for (int i=1; i<=m; ++i){
int x, y; cin >> x >> y;
edge[i]={x, y};
sus&=x==1;
}
if (sus){
for (int i=1; i<=q; ++i){
int l, r; cin >> l >> r;
qq[l].emplace_back(r, i);
}
DSU dsu;
dsu.init(n);
for (int i=1; i<=m; ++i){
if (qq[i].size()){
DSU dsu2=dsu;
sort(qq[i].rbegin(), qq[i].rend());
int cur=m;
for (auto &j:qq[i]){
while (cur>j.first){
dsu2.union_sets(edge[cur].first, edge[cur].second);
--cur;
}
ans[j.second]=!dsu2.ans;
}
}
dsu.union_sets(edge[i].first, edge[i].second);
}
}else{
for (int i=1; i<=q; ++i){
int l, r; cin >> l >> r;
qq[r].emplace_back(l, i);
}
DSU dsu;
dsu.init(n);
for (int i=m; i>=1; --i){
if (qq[i].size()){
DSU dsu2=dsu;
sort(qq[i].begin(), qq[i].end());
int cur=1;
for (auto &j:qq[i]){
while (cur<j.first){
dsu2.union_sets(edge[cur].first, edge[cur].second);
++cur;
}
ans[j.second]=!dsu2.ans;
}
}
dsu.union_sets(edge[i].first, edge[i].second);
}
}
for (int i=1; i<=q; ++i) cout << (ans[i]?"YES\n":"NO\n");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6784 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
6744 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
1 ms |
6788 KB |
Output is correct |
14 |
Correct |
1 ms |
6752 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
6748 KB |
Output is correct |
21 |
Correct |
2 ms |
6748 KB |
Output is correct |
22 |
Correct |
1 ms |
6744 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6744 KB |
Output is correct |
25 |
Correct |
2 ms |
6744 KB |
Output is correct |
26 |
Correct |
1 ms |
6748 KB |
Output is correct |
27 |
Correct |
2 ms |
6748 KB |
Output is correct |
28 |
Correct |
2 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6784 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
6744 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
1 ms |
6788 KB |
Output is correct |
14 |
Correct |
1 ms |
6752 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
6748 KB |
Output is correct |
21 |
Correct |
2 ms |
6748 KB |
Output is correct |
22 |
Correct |
1 ms |
6744 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6744 KB |
Output is correct |
25 |
Correct |
2 ms |
6744 KB |
Output is correct |
26 |
Correct |
1 ms |
6748 KB |
Output is correct |
27 |
Correct |
2 ms |
6748 KB |
Output is correct |
28 |
Correct |
2 ms |
6748 KB |
Output is correct |
29 |
Correct |
4 ms |
6748 KB |
Output is correct |
30 |
Correct |
6 ms |
6748 KB |
Output is correct |
31 |
Correct |
7 ms |
6748 KB |
Output is correct |
32 |
Correct |
6 ms |
6748 KB |
Output is correct |
33 |
Correct |
5 ms |
6748 KB |
Output is correct |
34 |
Correct |
6 ms |
6744 KB |
Output is correct |
35 |
Correct |
7 ms |
6748 KB |
Output is correct |
36 |
Correct |
5 ms |
6748 KB |
Output is correct |
37 |
Correct |
6 ms |
6748 KB |
Output is correct |
38 |
Correct |
10 ms |
6748 KB |
Output is correct |
39 |
Correct |
5 ms |
6748 KB |
Output is correct |
40 |
Correct |
5 ms |
6748 KB |
Output is correct |
41 |
Correct |
5 ms |
6752 KB |
Output is correct |
42 |
Correct |
5 ms |
6748 KB |
Output is correct |
43 |
Correct |
10 ms |
6748 KB |
Output is correct |
44 |
Correct |
11 ms |
6748 KB |
Output is correct |
45 |
Correct |
13 ms |
6748 KB |
Output is correct |
46 |
Correct |
14 ms |
6744 KB |
Output is correct |
47 |
Correct |
5 ms |
6744 KB |
Output is correct |
48 |
Correct |
6 ms |
6748 KB |
Output is correct |
49 |
Correct |
6 ms |
6744 KB |
Output is correct |
50 |
Correct |
6 ms |
6748 KB |
Output is correct |
51 |
Correct |
5 ms |
6756 KB |
Output is correct |
52 |
Correct |
6 ms |
6748 KB |
Output is correct |
53 |
Correct |
6 ms |
6744 KB |
Output is correct |
54 |
Correct |
8 ms |
7004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
1884 ms |
12740 KB |
Output is correct |
4 |
Execution timed out |
2053 ms |
13884 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6784 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
6744 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
1 ms |
6788 KB |
Output is correct |
14 |
Correct |
1 ms |
6752 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
6748 KB |
Output is correct |
21 |
Correct |
2 ms |
6748 KB |
Output is correct |
22 |
Correct |
1 ms |
6744 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6744 KB |
Output is correct |
25 |
Correct |
2 ms |
6744 KB |
Output is correct |
26 |
Correct |
1 ms |
6748 KB |
Output is correct |
27 |
Correct |
2 ms |
6748 KB |
Output is correct |
28 |
Correct |
2 ms |
6748 KB |
Output is correct |
29 |
Correct |
1884 ms |
12740 KB |
Output is correct |
30 |
Execution timed out |
2053 ms |
13884 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6784 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
6744 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
1 ms |
6788 KB |
Output is correct |
14 |
Correct |
1 ms |
6752 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
6748 KB |
Output is correct |
21 |
Correct |
2 ms |
6748 KB |
Output is correct |
22 |
Correct |
1 ms |
6744 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6744 KB |
Output is correct |
25 |
Correct |
2 ms |
6744 KB |
Output is correct |
26 |
Correct |
1 ms |
6748 KB |
Output is correct |
27 |
Correct |
2 ms |
6748 KB |
Output is correct |
28 |
Correct |
2 ms |
6748 KB |
Output is correct |
29 |
Correct |
4 ms |
6748 KB |
Output is correct |
30 |
Correct |
6 ms |
6748 KB |
Output is correct |
31 |
Correct |
7 ms |
6748 KB |
Output is correct |
32 |
Correct |
6 ms |
6748 KB |
Output is correct |
33 |
Correct |
5 ms |
6748 KB |
Output is correct |
34 |
Correct |
6 ms |
6744 KB |
Output is correct |
35 |
Correct |
7 ms |
6748 KB |
Output is correct |
36 |
Correct |
5 ms |
6748 KB |
Output is correct |
37 |
Correct |
6 ms |
6748 KB |
Output is correct |
38 |
Correct |
10 ms |
6748 KB |
Output is correct |
39 |
Correct |
5 ms |
6748 KB |
Output is correct |
40 |
Correct |
5 ms |
6748 KB |
Output is correct |
41 |
Correct |
5 ms |
6752 KB |
Output is correct |
42 |
Correct |
5 ms |
6748 KB |
Output is correct |
43 |
Correct |
10 ms |
6748 KB |
Output is correct |
44 |
Correct |
11 ms |
6748 KB |
Output is correct |
45 |
Correct |
13 ms |
6748 KB |
Output is correct |
46 |
Correct |
14 ms |
6744 KB |
Output is correct |
47 |
Correct |
5 ms |
6744 KB |
Output is correct |
48 |
Correct |
6 ms |
6748 KB |
Output is correct |
49 |
Correct |
6 ms |
6744 KB |
Output is correct |
50 |
Correct |
6 ms |
6748 KB |
Output is correct |
51 |
Correct |
5 ms |
6756 KB |
Output is correct |
52 |
Correct |
6 ms |
6748 KB |
Output is correct |
53 |
Correct |
6 ms |
6744 KB |
Output is correct |
54 |
Correct |
8 ms |
7004 KB |
Output is correct |
55 |
Correct |
1387 ms |
11288 KB |
Output is correct |
56 |
Execution timed out |
2045 ms |
13172 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6784 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
6744 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
1 ms |
6788 KB |
Output is correct |
14 |
Correct |
1 ms |
6752 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
6748 KB |
Output is correct |
21 |
Correct |
2 ms |
6748 KB |
Output is correct |
22 |
Correct |
1 ms |
6744 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6744 KB |
Output is correct |
25 |
Correct |
2 ms |
6744 KB |
Output is correct |
26 |
Correct |
1 ms |
6748 KB |
Output is correct |
27 |
Correct |
2 ms |
6748 KB |
Output is correct |
28 |
Correct |
2 ms |
6748 KB |
Output is correct |
29 |
Correct |
4 ms |
6748 KB |
Output is correct |
30 |
Correct |
6 ms |
6748 KB |
Output is correct |
31 |
Correct |
7 ms |
6748 KB |
Output is correct |
32 |
Correct |
6 ms |
6748 KB |
Output is correct |
33 |
Correct |
5 ms |
6748 KB |
Output is correct |
34 |
Correct |
6 ms |
6744 KB |
Output is correct |
35 |
Correct |
7 ms |
6748 KB |
Output is correct |
36 |
Correct |
5 ms |
6748 KB |
Output is correct |
37 |
Correct |
6 ms |
6748 KB |
Output is correct |
38 |
Correct |
10 ms |
6748 KB |
Output is correct |
39 |
Correct |
5 ms |
6748 KB |
Output is correct |
40 |
Correct |
5 ms |
6748 KB |
Output is correct |
41 |
Correct |
5 ms |
6752 KB |
Output is correct |
42 |
Correct |
5 ms |
6748 KB |
Output is correct |
43 |
Correct |
10 ms |
6748 KB |
Output is correct |
44 |
Correct |
11 ms |
6748 KB |
Output is correct |
45 |
Correct |
13 ms |
6748 KB |
Output is correct |
46 |
Correct |
14 ms |
6744 KB |
Output is correct |
47 |
Correct |
5 ms |
6744 KB |
Output is correct |
48 |
Correct |
6 ms |
6748 KB |
Output is correct |
49 |
Correct |
6 ms |
6744 KB |
Output is correct |
50 |
Correct |
6 ms |
6748 KB |
Output is correct |
51 |
Correct |
5 ms |
6756 KB |
Output is correct |
52 |
Correct |
6 ms |
6748 KB |
Output is correct |
53 |
Correct |
6 ms |
6744 KB |
Output is correct |
54 |
Correct |
8 ms |
7004 KB |
Output is correct |
55 |
Correct |
1884 ms |
12740 KB |
Output is correct |
56 |
Execution timed out |
2053 ms |
13884 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |