# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257399 |
2020-08-04T08:32:52 Z |
easrui |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
6552 KB |
#include <bits/stdc++.h>
#define va first
#define vb second
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N,M,Q,pos;
int par[MN<<1],sz[MN<<1],ans[MN];
pii E[MN];
vector<pii> qu;
vector<int> cnt;
int fnd(int u)
{
return u==par[u] ? u : fnd(par[u]);
}
void join(int u, int v)
{
u = fnd(u), v = fnd(v);
if(sz[u]>sz[v]) swap(u,v);
qu.push_back({u,v});
par[u] = v;
sz[v] += sz[u];
}
void upt(int x)
{
if(x>M){
join(0,0);
join(0,0);
cnt.push_back(0);
return;
}
if(!x){
for(int i=0; i<2; i++){
pii q = qu.back();
sz[q.vb] -= sz[q.va];
par[q.va] = q.va;
qu.pop_back();
}
pos -= cnt.back();
cnt.pop_back();
}
else{
join(E[x].va,E[x].vb+N);
join(E[x].va+N,E[x].vb);
if(fnd(E[x].va)==fnd(E[x].va+N)){
pos++;
cnt.push_back(1);
}
else cnt.push_back(0);
}
}
void solve(int s, int e, int x, int y)
{
if(s>e) return;
int m = (s+e)/2;
int z = y;
for(int i=s; i<m; i++) upt(i);
while(1){
upt(z);
if(pos||z==m){
ans[m] = z;
break;
}
z--;
}
for(int i=z; i<=y; i++) upt(0);
for(int i=s; i<m; i++) upt(0);
for(int i=z+1; i<=y; i++) upt(i);
solve(s,m-1,x,z);
for(int i=z+1; i<=y; i++) upt(0);
for(int i=s; i<=m; i++) upt(i);
solve(m+1,e,max(m+1,z),y);
for(int i=s; i<=m; i++) upt(0);
}
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> N >> M >> Q;
for(int i=1; i<=M; i++) cin >> E[i].va >> E[i].vb;
for(int i=1; i<=2*N; i++){
par[i] = i;
sz[i] = 1;
}
solve(1,M,1,M+1);
while(Q--){
int l,r;
cin >> l >> r;
cout << (r<ans[l] ? "YES\n" : "NO\n");
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
10 ms |
512 KB |
Output is correct |
31 |
Correct |
23 ms |
512 KB |
Output is correct |
32 |
Correct |
30 ms |
512 KB |
Output is correct |
33 |
Correct |
31 ms |
504 KB |
Output is correct |
34 |
Correct |
14 ms |
512 KB |
Output is correct |
35 |
Correct |
17 ms |
512 KB |
Output is correct |
36 |
Correct |
42 ms |
504 KB |
Output is correct |
37 |
Correct |
11 ms |
512 KB |
Output is correct |
38 |
Correct |
4 ms |
512 KB |
Output is correct |
39 |
Correct |
21 ms |
512 KB |
Output is correct |
40 |
Correct |
6 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
512 KB |
Output is correct |
42 |
Correct |
7 ms |
512 KB |
Output is correct |
43 |
Correct |
20 ms |
512 KB |
Output is correct |
44 |
Correct |
23 ms |
512 KB |
Output is correct |
45 |
Correct |
23 ms |
512 KB |
Output is correct |
46 |
Correct |
16 ms |
512 KB |
Output is correct |
47 |
Correct |
27 ms |
504 KB |
Output is correct |
48 |
Correct |
13 ms |
512 KB |
Output is correct |
49 |
Correct |
15 ms |
512 KB |
Output is correct |
50 |
Correct |
17 ms |
632 KB |
Output is correct |
51 |
Correct |
24 ms |
512 KB |
Output is correct |
52 |
Correct |
24 ms |
512 KB |
Output is correct |
53 |
Correct |
25 ms |
512 KB |
Output is correct |
54 |
Correct |
15 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
2079 ms |
6552 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Execution timed out |
2079 ms |
6552 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
10 ms |
512 KB |
Output is correct |
31 |
Correct |
23 ms |
512 KB |
Output is correct |
32 |
Correct |
30 ms |
512 KB |
Output is correct |
33 |
Correct |
31 ms |
504 KB |
Output is correct |
34 |
Correct |
14 ms |
512 KB |
Output is correct |
35 |
Correct |
17 ms |
512 KB |
Output is correct |
36 |
Correct |
42 ms |
504 KB |
Output is correct |
37 |
Correct |
11 ms |
512 KB |
Output is correct |
38 |
Correct |
4 ms |
512 KB |
Output is correct |
39 |
Correct |
21 ms |
512 KB |
Output is correct |
40 |
Correct |
6 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
512 KB |
Output is correct |
42 |
Correct |
7 ms |
512 KB |
Output is correct |
43 |
Correct |
20 ms |
512 KB |
Output is correct |
44 |
Correct |
23 ms |
512 KB |
Output is correct |
45 |
Correct |
23 ms |
512 KB |
Output is correct |
46 |
Correct |
16 ms |
512 KB |
Output is correct |
47 |
Correct |
27 ms |
504 KB |
Output is correct |
48 |
Correct |
13 ms |
512 KB |
Output is correct |
49 |
Correct |
15 ms |
512 KB |
Output is correct |
50 |
Correct |
17 ms |
632 KB |
Output is correct |
51 |
Correct |
24 ms |
512 KB |
Output is correct |
52 |
Correct |
24 ms |
512 KB |
Output is correct |
53 |
Correct |
25 ms |
512 KB |
Output is correct |
54 |
Correct |
15 ms |
512 KB |
Output is correct |
55 |
Execution timed out |
2045 ms |
6420 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
10 ms |
512 KB |
Output is correct |
31 |
Correct |
23 ms |
512 KB |
Output is correct |
32 |
Correct |
30 ms |
512 KB |
Output is correct |
33 |
Correct |
31 ms |
504 KB |
Output is correct |
34 |
Correct |
14 ms |
512 KB |
Output is correct |
35 |
Correct |
17 ms |
512 KB |
Output is correct |
36 |
Correct |
42 ms |
504 KB |
Output is correct |
37 |
Correct |
11 ms |
512 KB |
Output is correct |
38 |
Correct |
4 ms |
512 KB |
Output is correct |
39 |
Correct |
21 ms |
512 KB |
Output is correct |
40 |
Correct |
6 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
512 KB |
Output is correct |
42 |
Correct |
7 ms |
512 KB |
Output is correct |
43 |
Correct |
20 ms |
512 KB |
Output is correct |
44 |
Correct |
23 ms |
512 KB |
Output is correct |
45 |
Correct |
23 ms |
512 KB |
Output is correct |
46 |
Correct |
16 ms |
512 KB |
Output is correct |
47 |
Correct |
27 ms |
504 KB |
Output is correct |
48 |
Correct |
13 ms |
512 KB |
Output is correct |
49 |
Correct |
15 ms |
512 KB |
Output is correct |
50 |
Correct |
17 ms |
632 KB |
Output is correct |
51 |
Correct |
24 ms |
512 KB |
Output is correct |
52 |
Correct |
24 ms |
512 KB |
Output is correct |
53 |
Correct |
25 ms |
512 KB |
Output is correct |
54 |
Correct |
15 ms |
512 KB |
Output is correct |
55 |
Execution timed out |
2079 ms |
6552 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |