# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649810 | 2022-10-11T11:05:14 Z | DJeniUp | Joker (BOI20_joker) | C++17 | 2000 ms | 10504 KB |
#include "bits/stdc++.h" //#pragma GCC optimize("O3") using namespace std; typedef int 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(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //cin>>n>>m>>q; scanf("%d %d %d", &n, &m, &q); //s.insert(0); for(int i=1;i<=m;i++){ //cin>>d[i].l>>d[i].r; scanf("%d %d", &d[i].l, &d[i].r); } for(int i=1;i<=q;i++){ //cin>>o[i].l>>o[i].r; scanf("%d %d", &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)printf("YES\n"); else printf("NO\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 38 ms | 412 KB | Output is correct |
30 | Correct | 76 ms | 560 KB | Output is correct |
31 | Correct | 88 ms | 340 KB | Output is correct |
32 | Correct | 75 ms | 436 KB | Output is correct |
33 | Correct | 66 ms | 456 KB | Output is correct |
34 | Correct | 70 ms | 440 KB | Output is correct |
35 | Correct | 78 ms | 456 KB | Output is correct |
36 | Correct | 61 ms | 432 KB | Output is correct |
37 | Correct | 107 ms | 444 KB | Output is correct |
38 | Correct | 119 ms | 440 KB | Output is correct |
39 | Correct | 67 ms | 460 KB | Output is correct |
40 | Correct | 55 ms | 452 KB | Output is correct |
41 | Correct | 59 ms | 436 KB | Output is correct |
42 | Correct | 69 ms | 452 KB | Output is correct |
43 | Correct | 66 ms | 448 KB | Output is correct |
44 | Correct | 69 ms | 436 KB | Output is correct |
45 | Correct | 70 ms | 340 KB | Output is correct |
46 | Correct | 81 ms | 452 KB | Output is correct |
47 | Correct | 73 ms | 448 KB | Output is correct |
48 | Correct | 72 ms | 460 KB | Output is correct |
49 | Correct | 69 ms | 456 KB | Output is correct |
50 | Correct | 74 ms | 340 KB | Output is correct |
51 | Correct | 70 ms | 452 KB | Output is correct |
52 | Correct | 77 ms | 340 KB | Output is correct |
53 | Correct | 76 ms | 448 KB | Output is correct |
54 | Correct | 79 ms | 448 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 79 ms | 5656 KB | Output is correct |
4 | Correct | 98 ms | 6056 KB | Output is correct |
5 | Correct | 89 ms | 5488 KB | Output is correct |
6 | Correct | 81 ms | 5148 KB | Output is correct |
7 | Correct | 85 ms | 4784 KB | Output is correct |
8 | Correct | 87 ms | 4688 KB | Output is correct |
9 | Correct | 101 ms | 4940 KB | Output is correct |
10 | Correct | 82 ms | 5684 KB | Output is correct |
11 | Correct | 85 ms | 4956 KB | Output is correct |
12 | Correct | 83 ms | 5972 KB | Output is correct |
13 | Correct | 91 ms | 4172 KB | Output is correct |
14 | Correct | 80 ms | 4432 KB | Output is correct |
15 | Correct | 84 ms | 5180 KB | Output is correct |
16 | Correct | 90 ms | 5520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 79 ms | 5656 KB | Output is correct |
30 | Correct | 98 ms | 6056 KB | Output is correct |
31 | Correct | 89 ms | 5488 KB | Output is correct |
32 | Correct | 81 ms | 5148 KB | Output is correct |
33 | Correct | 85 ms | 4784 KB | Output is correct |
34 | Correct | 87 ms | 4688 KB | Output is correct |
35 | Correct | 101 ms | 4940 KB | Output is correct |
36 | Correct | 82 ms | 5684 KB | Output is correct |
37 | Correct | 85 ms | 4956 KB | Output is correct |
38 | Correct | 83 ms | 5972 KB | Output is correct |
39 | Correct | 91 ms | 4172 KB | Output is correct |
40 | Correct | 80 ms | 4432 KB | Output is correct |
41 | Correct | 84 ms | 5180 KB | Output is correct |
42 | Correct | 90 ms | 5520 KB | Output is correct |
43 | Correct | 914 ms | 5564 KB | Output is correct |
44 | Correct | 1988 ms | 6016 KB | Output is correct |
45 | Correct | 1877 ms | 9944 KB | Output is correct |
46 | Correct | 157 ms | 9484 KB | Output is correct |
47 | Correct | 176 ms | 9128 KB | Output is correct |
48 | Correct | 793 ms | 8840 KB | Output is correct |
49 | Correct | 1312 ms | 9824 KB | Output is correct |
50 | Correct | 1394 ms | 9148 KB | Output is correct |
51 | Correct | 1316 ms | 9716 KB | Output is correct |
52 | Correct | 1193 ms | 10504 KB | Output is correct |
53 | Correct | 913 ms | 8496 KB | Output is correct |
54 | Correct | 717 ms | 9164 KB | Output is correct |
55 | Correct | 1060 ms | 9640 KB | Output is correct |
56 | Correct | 1279 ms | 10000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 38 ms | 412 KB | Output is correct |
30 | Correct | 76 ms | 560 KB | Output is correct |
31 | Correct | 88 ms | 340 KB | Output is correct |
32 | Correct | 75 ms | 436 KB | Output is correct |
33 | Correct | 66 ms | 456 KB | Output is correct |
34 | Correct | 70 ms | 440 KB | Output is correct |
35 | Correct | 78 ms | 456 KB | Output is correct |
36 | Correct | 61 ms | 432 KB | Output is correct |
37 | Correct | 107 ms | 444 KB | Output is correct |
38 | Correct | 119 ms | 440 KB | Output is correct |
39 | Correct | 67 ms | 460 KB | Output is correct |
40 | Correct | 55 ms | 452 KB | Output is correct |
41 | Correct | 59 ms | 436 KB | Output is correct |
42 | Correct | 69 ms | 452 KB | Output is correct |
43 | Correct | 66 ms | 448 KB | Output is correct |
44 | Correct | 69 ms | 436 KB | Output is correct |
45 | Correct | 70 ms | 340 KB | Output is correct |
46 | Correct | 81 ms | 452 KB | Output is correct |
47 | Correct | 73 ms | 448 KB | Output is correct |
48 | Correct | 72 ms | 460 KB | Output is correct |
49 | Correct | 69 ms | 456 KB | Output is correct |
50 | Correct | 74 ms | 340 KB | Output is correct |
51 | Correct | 70 ms | 452 KB | Output is correct |
52 | Correct | 77 ms | 340 KB | Output is correct |
53 | Correct | 76 ms | 448 KB | Output is correct |
54 | Correct | 79 ms | 448 KB | Output is correct |
55 | Execution timed out | 2092 ms | 3004 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 38 ms | 412 KB | Output is correct |
30 | Correct | 76 ms | 560 KB | Output is correct |
31 | Correct | 88 ms | 340 KB | Output is correct |
32 | Correct | 75 ms | 436 KB | Output is correct |
33 | Correct | 66 ms | 456 KB | Output is correct |
34 | Correct | 70 ms | 440 KB | Output is correct |
35 | Correct | 78 ms | 456 KB | Output is correct |
36 | Correct | 61 ms | 432 KB | Output is correct |
37 | Correct | 107 ms | 444 KB | Output is correct |
38 | Correct | 119 ms | 440 KB | Output is correct |
39 | Correct | 67 ms | 460 KB | Output is correct |
40 | Correct | 55 ms | 452 KB | Output is correct |
41 | Correct | 59 ms | 436 KB | Output is correct |
42 | Correct | 69 ms | 452 KB | Output is correct |
43 | Correct | 66 ms | 448 KB | Output is correct |
44 | Correct | 69 ms | 436 KB | Output is correct |
45 | Correct | 70 ms | 340 KB | Output is correct |
46 | Correct | 81 ms | 452 KB | Output is correct |
47 | Correct | 73 ms | 448 KB | Output is correct |
48 | Correct | 72 ms | 460 KB | Output is correct |
49 | Correct | 69 ms | 456 KB | Output is correct |
50 | Correct | 74 ms | 340 KB | Output is correct |
51 | Correct | 70 ms | 452 KB | Output is correct |
52 | Correct | 77 ms | 340 KB | Output is correct |
53 | Correct | 76 ms | 448 KB | Output is correct |
54 | Correct | 79 ms | 448 KB | Output is correct |
55 | Correct | 79 ms | 5656 KB | Output is correct |
56 | Correct | 98 ms | 6056 KB | Output is correct |
57 | Correct | 89 ms | 5488 KB | Output is correct |
58 | Correct | 81 ms | 5148 KB | Output is correct |
59 | Correct | 85 ms | 4784 KB | Output is correct |
60 | Correct | 87 ms | 4688 KB | Output is correct |
61 | Correct | 101 ms | 4940 KB | Output is correct |
62 | Correct | 82 ms | 5684 KB | Output is correct |
63 | Correct | 85 ms | 4956 KB | Output is correct |
64 | Correct | 83 ms | 5972 KB | Output is correct |
65 | Correct | 91 ms | 4172 KB | Output is correct |
66 | Correct | 80 ms | 4432 KB | Output is correct |
67 | Correct | 84 ms | 5180 KB | Output is correct |
68 | Correct | 90 ms | 5520 KB | Output is correct |
69 | Correct | 914 ms | 5564 KB | Output is correct |
70 | Correct | 1988 ms | 6016 KB | Output is correct |
71 | Correct | 1877 ms | 9944 KB | Output is correct |
72 | Correct | 157 ms | 9484 KB | Output is correct |
73 | Correct | 176 ms | 9128 KB | Output is correct |
74 | Correct | 793 ms | 8840 KB | Output is correct |
75 | Correct | 1312 ms | 9824 KB | Output is correct |
76 | Correct | 1394 ms | 9148 KB | Output is correct |
77 | Correct | 1316 ms | 9716 KB | Output is correct |
78 | Correct | 1193 ms | 10504 KB | Output is correct |
79 | Correct | 913 ms | 8496 KB | Output is correct |
80 | Correct | 717 ms | 9164 KB | Output is correct |
81 | Correct | 1060 ms | 9640 KB | Output is correct |
82 | Correct | 1279 ms | 10000 KB | Output is correct |
83 | Execution timed out | 2092 ms | 3004 KB | Time limit exceeded |
84 | Halted | 0 ms | 0 KB | - |