# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
649806 |
2022-10-11T11:01:28 Z |
DJeniUp |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
10680 KB |
#include "bits/stdc++.h"
//#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
#define INF 100000000007
#define endl '\n'
#define MOD 998244353
#define N 200007
ll n,m,q,p[N],res[N],h[N],f,k;
struct Q{
ll l,r;
}o[N];
struct D{
ll l,r;
}d[N];
set<ll>s;
ll P(ll x){
if(p[x]!=x){
ll g=P(p[x]);
h[x]+=h[p[x]];
h[x]%=2;
p[x]=g;
}
return p[x];
}
ll H(ll x){
ll r1=0;
while(p[x]!=x){
r1+=h[x];
x=p[x];
}
return r1;
}
void A(ll x,ll y){
if(rand()%2)swap(x,y);
ll x1=P(x);
ll y1=P(y);
h[x1]=H(x)+1+H(y);
h[x1]%=2;
p[x1]=y1;
return ;
}
int main(){
cin>>n>>m>>q;
//s.insert(0);
for(int i=1;i<=m;i++){
cin>>d[i].l>>d[i].r;
}
for(int i=1;i<=q;i++){
cin>>o[i].l>>o[i].r;
s.insert(o[i].l-1);
}
for(auto it:s){
res[it]=0;
for(int i=1;i<=n;i++){
p[i]=i;
h[i]=0;
}
for(int i=1;i<=it;i++){
if(P(d[i].l)!=P(d[i].r)){
A(d[i].l,d[i].r);
}else if(H(d[i].l)%2==H(d[i].r)%2){
res[it]=m+1;
}
}
if(res[it]!=0)continue;
for(int i=m;i>=it;i--){
if(P(d[i].l)==P(d[i].r) && H(d[i].l)%2==H(d[i].r)%2){
res[it]=i;
break;
}else if(P(d[i].l)!=P(d[i].r))A(d[i].l,d[i].r);
}
}
for(int i=1;i<=q;i++){
if(res[o[i].l-1]>o[i].r)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
284 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
284 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
356 KB |
Output is correct |
29 |
Correct |
49 ms |
456 KB |
Output is correct |
30 |
Correct |
77 ms |
468 KB |
Output is correct |
31 |
Correct |
100 ms |
492 KB |
Output is correct |
32 |
Correct |
89 ms |
480 KB |
Output is correct |
33 |
Correct |
75 ms |
484 KB |
Output is correct |
34 |
Correct |
85 ms |
496 KB |
Output is correct |
35 |
Correct |
96 ms |
496 KB |
Output is correct |
36 |
Correct |
75 ms |
484 KB |
Output is correct |
37 |
Correct |
109 ms |
504 KB |
Output is correct |
38 |
Correct |
135 ms |
496 KB |
Output is correct |
39 |
Correct |
88 ms |
496 KB |
Output is correct |
40 |
Correct |
64 ms |
528 KB |
Output is correct |
41 |
Correct |
77 ms |
536 KB |
Output is correct |
42 |
Correct |
67 ms |
520 KB |
Output is correct |
43 |
Correct |
72 ms |
508 KB |
Output is correct |
44 |
Correct |
84 ms |
528 KB |
Output is correct |
45 |
Correct |
83 ms |
548 KB |
Output is correct |
46 |
Correct |
99 ms |
524 KB |
Output is correct |
47 |
Correct |
74 ms |
508 KB |
Output is correct |
48 |
Correct |
85 ms |
520 KB |
Output is correct |
49 |
Correct |
81 ms |
520 KB |
Output is correct |
50 |
Correct |
101 ms |
540 KB |
Output is correct |
51 |
Correct |
78 ms |
516 KB |
Output is correct |
52 |
Correct |
83 ms |
512 KB |
Output is correct |
53 |
Correct |
91 ms |
532 KB |
Output is correct |
54 |
Correct |
90 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
232 ms |
9452 KB |
Output is correct |
4 |
Correct |
245 ms |
10680 KB |
Output is correct |
5 |
Correct |
256 ms |
10028 KB |
Output is correct |
6 |
Correct |
242 ms |
9036 KB |
Output is correct |
7 |
Correct |
237 ms |
8656 KB |
Output is correct |
8 |
Correct |
212 ms |
8232 KB |
Output is correct |
9 |
Correct |
202 ms |
8876 KB |
Output is correct |
10 |
Correct |
245 ms |
10324 KB |
Output is correct |
11 |
Correct |
234 ms |
8876 KB |
Output is correct |
12 |
Correct |
236 ms |
10556 KB |
Output is correct |
13 |
Correct |
231 ms |
7484 KB |
Output is correct |
14 |
Correct |
233 ms |
8104 KB |
Output is correct |
15 |
Correct |
228 ms |
9276 KB |
Output is correct |
16 |
Correct |
226 ms |
10316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
284 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
356 KB |
Output is correct |
29 |
Correct |
232 ms |
9452 KB |
Output is correct |
30 |
Correct |
245 ms |
10680 KB |
Output is correct |
31 |
Correct |
256 ms |
10028 KB |
Output is correct |
32 |
Correct |
242 ms |
9036 KB |
Output is correct |
33 |
Correct |
237 ms |
8656 KB |
Output is correct |
34 |
Correct |
212 ms |
8232 KB |
Output is correct |
35 |
Correct |
202 ms |
8876 KB |
Output is correct |
36 |
Correct |
245 ms |
10324 KB |
Output is correct |
37 |
Correct |
234 ms |
8876 KB |
Output is correct |
38 |
Correct |
236 ms |
10556 KB |
Output is correct |
39 |
Correct |
231 ms |
7484 KB |
Output is correct |
40 |
Correct |
233 ms |
8104 KB |
Output is correct |
41 |
Correct |
228 ms |
9276 KB |
Output is correct |
42 |
Correct |
226 ms |
10316 KB |
Output is correct |
43 |
Correct |
1221 ms |
9564 KB |
Output is correct |
44 |
Execution timed out |
2056 ms |
10060 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
284 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
356 KB |
Output is correct |
29 |
Correct |
49 ms |
456 KB |
Output is correct |
30 |
Correct |
77 ms |
468 KB |
Output is correct |
31 |
Correct |
100 ms |
492 KB |
Output is correct |
32 |
Correct |
89 ms |
480 KB |
Output is correct |
33 |
Correct |
75 ms |
484 KB |
Output is correct |
34 |
Correct |
85 ms |
496 KB |
Output is correct |
35 |
Correct |
96 ms |
496 KB |
Output is correct |
36 |
Correct |
75 ms |
484 KB |
Output is correct |
37 |
Correct |
109 ms |
504 KB |
Output is correct |
38 |
Correct |
135 ms |
496 KB |
Output is correct |
39 |
Correct |
88 ms |
496 KB |
Output is correct |
40 |
Correct |
64 ms |
528 KB |
Output is correct |
41 |
Correct |
77 ms |
536 KB |
Output is correct |
42 |
Correct |
67 ms |
520 KB |
Output is correct |
43 |
Correct |
72 ms |
508 KB |
Output is correct |
44 |
Correct |
84 ms |
528 KB |
Output is correct |
45 |
Correct |
83 ms |
548 KB |
Output is correct |
46 |
Correct |
99 ms |
524 KB |
Output is correct |
47 |
Correct |
74 ms |
508 KB |
Output is correct |
48 |
Correct |
85 ms |
520 KB |
Output is correct |
49 |
Correct |
81 ms |
520 KB |
Output is correct |
50 |
Correct |
101 ms |
540 KB |
Output is correct |
51 |
Correct |
78 ms |
516 KB |
Output is correct |
52 |
Correct |
83 ms |
512 KB |
Output is correct |
53 |
Correct |
91 ms |
532 KB |
Output is correct |
54 |
Correct |
90 ms |
536 KB |
Output is correct |
55 |
Execution timed out |
2039 ms |
6116 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
284 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
356 KB |
Output is correct |
29 |
Correct |
49 ms |
456 KB |
Output is correct |
30 |
Correct |
77 ms |
468 KB |
Output is correct |
31 |
Correct |
100 ms |
492 KB |
Output is correct |
32 |
Correct |
89 ms |
480 KB |
Output is correct |
33 |
Correct |
75 ms |
484 KB |
Output is correct |
34 |
Correct |
85 ms |
496 KB |
Output is correct |
35 |
Correct |
96 ms |
496 KB |
Output is correct |
36 |
Correct |
75 ms |
484 KB |
Output is correct |
37 |
Correct |
109 ms |
504 KB |
Output is correct |
38 |
Correct |
135 ms |
496 KB |
Output is correct |
39 |
Correct |
88 ms |
496 KB |
Output is correct |
40 |
Correct |
64 ms |
528 KB |
Output is correct |
41 |
Correct |
77 ms |
536 KB |
Output is correct |
42 |
Correct |
67 ms |
520 KB |
Output is correct |
43 |
Correct |
72 ms |
508 KB |
Output is correct |
44 |
Correct |
84 ms |
528 KB |
Output is correct |
45 |
Correct |
83 ms |
548 KB |
Output is correct |
46 |
Correct |
99 ms |
524 KB |
Output is correct |
47 |
Correct |
74 ms |
508 KB |
Output is correct |
48 |
Correct |
85 ms |
520 KB |
Output is correct |
49 |
Correct |
81 ms |
520 KB |
Output is correct |
50 |
Correct |
101 ms |
540 KB |
Output is correct |
51 |
Correct |
78 ms |
516 KB |
Output is correct |
52 |
Correct |
83 ms |
512 KB |
Output is correct |
53 |
Correct |
91 ms |
532 KB |
Output is correct |
54 |
Correct |
90 ms |
536 KB |
Output is correct |
55 |
Correct |
232 ms |
9452 KB |
Output is correct |
56 |
Correct |
245 ms |
10680 KB |
Output is correct |
57 |
Correct |
256 ms |
10028 KB |
Output is correct |
58 |
Correct |
242 ms |
9036 KB |
Output is correct |
59 |
Correct |
237 ms |
8656 KB |
Output is correct |
60 |
Correct |
212 ms |
8232 KB |
Output is correct |
61 |
Correct |
202 ms |
8876 KB |
Output is correct |
62 |
Correct |
245 ms |
10324 KB |
Output is correct |
63 |
Correct |
234 ms |
8876 KB |
Output is correct |
64 |
Correct |
236 ms |
10556 KB |
Output is correct |
65 |
Correct |
231 ms |
7484 KB |
Output is correct |
66 |
Correct |
233 ms |
8104 KB |
Output is correct |
67 |
Correct |
228 ms |
9276 KB |
Output is correct |
68 |
Correct |
226 ms |
10316 KB |
Output is correct |
69 |
Correct |
1221 ms |
9564 KB |
Output is correct |
70 |
Execution timed out |
2056 ms |
10060 KB |
Time limit exceeded |
71 |
Halted |
0 ms |
0 KB |
- |