# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
599291 |
2022-07-19T12:26:12 Z |
OttoTheDino |
Joker (BOI20_joker) |
C++17 |
|
1550 ms |
13896 KB |
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define fi first
#define se second
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> ii;
const int mx = 2e5;
vi adj[mx+1];
int par[mx+1], h[mx+1], tp[mx+1];
ii get_par (int u) {
if (u==par[u]) return {u, tp[u]};
ii res = get_par (par[u]);
return {res.fi, res.se^tp[u]};
}
void merge (int u, int v) {
ii paru = get_par(u), parv = get_par(v);
if (h[paru.fi]<h[parv.fi]) swap(paru, parv);
h[paru.fi] += h[paru.fi]==h[parv.fi];
par[parv.fi] = paru.fi;
tp[parv.fi] ^= parv.se==paru.se;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, q; cin >>n >> m >> q;
ii e[m+1];
rep (i,1,m) cin >> e[i].fi >> e[i].se;
int L = min(m,199);
if (n<=2000) L = m;
int ans[L+1] = {};
rep (i,0,L) {
bool got = 0;
rep (j,1,n) {
par[j] = j;
h[j] = 1;
tp[j] = 0;
}
rep (j,1,i) {
ii parj = get_par(e[j].fi), parv = get_par(e[j].se);
if (parj.fi==parv.fi) got |= (parj.se==parv.se);
else merge(e[j].fi,e[j].se);
}
rrep (j,m,i) {
if (got) {
ans[i] = j+1;
break;
}
ii parj = get_par(e[j].fi), parv = get_par(e[j].se);
if (parj.fi==parv.fi) got |= (parj.se==parv.se);
else merge(e[j].fi,e[j].se);
}
}
while (q--) {
int l, r; cin >> l >> r;
if (ans[l-1]>r) cout << "YES\n";
else cout << "NO\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
4 ms |
5028 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
5024 KB |
Output is correct |
14 |
Correct |
4 ms |
5020 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
5020 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
3 ms |
4948 KB |
Output is correct |
20 |
Correct |
4 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
4948 KB |
Output is correct |
22 |
Correct |
4 ms |
5020 KB |
Output is correct |
23 |
Correct |
3 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Correct |
3 ms |
4948 KB |
Output is correct |
26 |
Correct |
3 ms |
4948 KB |
Output is correct |
27 |
Correct |
3 ms |
4948 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
4 ms |
5028 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
5024 KB |
Output is correct |
14 |
Correct |
4 ms |
5020 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
5020 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
3 ms |
4948 KB |
Output is correct |
20 |
Correct |
4 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
4948 KB |
Output is correct |
22 |
Correct |
4 ms |
5020 KB |
Output is correct |
23 |
Correct |
3 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Correct |
3 ms |
4948 KB |
Output is correct |
26 |
Correct |
3 ms |
4948 KB |
Output is correct |
27 |
Correct |
3 ms |
4948 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
26 ms |
5072 KB |
Output is correct |
30 |
Correct |
62 ms |
5076 KB |
Output is correct |
31 |
Correct |
77 ms |
5096 KB |
Output is correct |
32 |
Correct |
69 ms |
5084 KB |
Output is correct |
33 |
Correct |
58 ms |
5076 KB |
Output is correct |
34 |
Correct |
67 ms |
5108 KB |
Output is correct |
35 |
Correct |
73 ms |
5100 KB |
Output is correct |
36 |
Correct |
55 ms |
5092 KB |
Output is correct |
37 |
Correct |
86 ms |
5076 KB |
Output is correct |
38 |
Correct |
116 ms |
5076 KB |
Output is correct |
39 |
Correct |
50 ms |
5092 KB |
Output is correct |
40 |
Correct |
55 ms |
5080 KB |
Output is correct |
41 |
Correct |
53 ms |
5076 KB |
Output is correct |
42 |
Correct |
51 ms |
5076 KB |
Output is correct |
43 |
Correct |
68 ms |
5088 KB |
Output is correct |
44 |
Correct |
74 ms |
5032 KB |
Output is correct |
45 |
Correct |
63 ms |
5092 KB |
Output is correct |
46 |
Correct |
73 ms |
5104 KB |
Output is correct |
47 |
Correct |
53 ms |
5076 KB |
Output is correct |
48 |
Correct |
68 ms |
5088 KB |
Output is correct |
49 |
Correct |
72 ms |
5088 KB |
Output is correct |
50 |
Correct |
75 ms |
5088 KB |
Output is correct |
51 |
Correct |
68 ms |
5076 KB |
Output is correct |
52 |
Correct |
64 ms |
5084 KB |
Output is correct |
53 |
Correct |
67 ms |
5028 KB |
Output is correct |
54 |
Correct |
87 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
691 ms |
12332 KB |
Output is correct |
4 |
Correct |
1550 ms |
12996 KB |
Output is correct |
5 |
Correct |
219 ms |
13544 KB |
Output is correct |
6 |
Correct |
168 ms |
12352 KB |
Output is correct |
7 |
Correct |
180 ms |
12364 KB |
Output is correct |
8 |
Correct |
409 ms |
11404 KB |
Output is correct |
9 |
Correct |
484 ms |
11836 KB |
Output is correct |
10 |
Correct |
927 ms |
13252 KB |
Output is correct |
11 |
Correct |
832 ms |
12352 KB |
Output is correct |
12 |
Correct |
765 ms |
13416 KB |
Output is correct |
13 |
Correct |
707 ms |
11280 KB |
Output is correct |
14 |
Correct |
441 ms |
11876 KB |
Output is correct |
15 |
Correct |
771 ms |
12832 KB |
Output is correct |
16 |
Correct |
908 ms |
13636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
4 ms |
5028 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
5024 KB |
Output is correct |
14 |
Correct |
4 ms |
5020 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
5020 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
3 ms |
4948 KB |
Output is correct |
20 |
Correct |
4 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
4948 KB |
Output is correct |
22 |
Correct |
4 ms |
5020 KB |
Output is correct |
23 |
Correct |
3 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Correct |
3 ms |
4948 KB |
Output is correct |
26 |
Correct |
3 ms |
4948 KB |
Output is correct |
27 |
Correct |
3 ms |
4948 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
691 ms |
12332 KB |
Output is correct |
30 |
Correct |
1550 ms |
12996 KB |
Output is correct |
31 |
Correct |
219 ms |
13544 KB |
Output is correct |
32 |
Correct |
168 ms |
12352 KB |
Output is correct |
33 |
Correct |
180 ms |
12364 KB |
Output is correct |
34 |
Correct |
409 ms |
11404 KB |
Output is correct |
35 |
Correct |
484 ms |
11836 KB |
Output is correct |
36 |
Correct |
927 ms |
13252 KB |
Output is correct |
37 |
Correct |
832 ms |
12352 KB |
Output is correct |
38 |
Correct |
765 ms |
13416 KB |
Output is correct |
39 |
Correct |
707 ms |
11280 KB |
Output is correct |
40 |
Correct |
441 ms |
11876 KB |
Output is correct |
41 |
Correct |
771 ms |
12832 KB |
Output is correct |
42 |
Correct |
908 ms |
13636 KB |
Output is correct |
43 |
Correct |
687 ms |
12608 KB |
Output is correct |
44 |
Correct |
1517 ms |
13512 KB |
Output is correct |
45 |
Correct |
1398 ms |
13824 KB |
Output is correct |
46 |
Correct |
137 ms |
12820 KB |
Output is correct |
47 |
Correct |
148 ms |
12836 KB |
Output is correct |
48 |
Correct |
532 ms |
12352 KB |
Output is correct |
49 |
Correct |
933 ms |
13632 KB |
Output is correct |
50 |
Correct |
848 ms |
12368 KB |
Output is correct |
51 |
Correct |
866 ms |
13204 KB |
Output is correct |
52 |
Correct |
802 ms |
13840 KB |
Output is correct |
53 |
Correct |
596 ms |
11584 KB |
Output is correct |
54 |
Correct |
544 ms |
12372 KB |
Output is correct |
55 |
Correct |
863 ms |
13204 KB |
Output is correct |
56 |
Correct |
975 ms |
13896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
4 ms |
5028 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
5024 KB |
Output is correct |
14 |
Correct |
4 ms |
5020 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
5020 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
3 ms |
4948 KB |
Output is correct |
20 |
Correct |
4 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
4948 KB |
Output is correct |
22 |
Correct |
4 ms |
5020 KB |
Output is correct |
23 |
Correct |
3 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Correct |
3 ms |
4948 KB |
Output is correct |
26 |
Correct |
3 ms |
4948 KB |
Output is correct |
27 |
Correct |
3 ms |
4948 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
26 ms |
5072 KB |
Output is correct |
30 |
Correct |
62 ms |
5076 KB |
Output is correct |
31 |
Correct |
77 ms |
5096 KB |
Output is correct |
32 |
Correct |
69 ms |
5084 KB |
Output is correct |
33 |
Correct |
58 ms |
5076 KB |
Output is correct |
34 |
Correct |
67 ms |
5108 KB |
Output is correct |
35 |
Correct |
73 ms |
5100 KB |
Output is correct |
36 |
Correct |
55 ms |
5092 KB |
Output is correct |
37 |
Correct |
86 ms |
5076 KB |
Output is correct |
38 |
Correct |
116 ms |
5076 KB |
Output is correct |
39 |
Correct |
50 ms |
5092 KB |
Output is correct |
40 |
Correct |
55 ms |
5080 KB |
Output is correct |
41 |
Correct |
53 ms |
5076 KB |
Output is correct |
42 |
Correct |
51 ms |
5076 KB |
Output is correct |
43 |
Correct |
68 ms |
5088 KB |
Output is correct |
44 |
Correct |
74 ms |
5032 KB |
Output is correct |
45 |
Correct |
63 ms |
5092 KB |
Output is correct |
46 |
Correct |
73 ms |
5104 KB |
Output is correct |
47 |
Correct |
53 ms |
5076 KB |
Output is correct |
48 |
Correct |
68 ms |
5088 KB |
Output is correct |
49 |
Correct |
72 ms |
5088 KB |
Output is correct |
50 |
Correct |
75 ms |
5088 KB |
Output is correct |
51 |
Correct |
68 ms |
5076 KB |
Output is correct |
52 |
Correct |
64 ms |
5084 KB |
Output is correct |
53 |
Correct |
67 ms |
5028 KB |
Output is correct |
54 |
Correct |
87 ms |
5076 KB |
Output is correct |
55 |
Incorrect |
632 ms |
10092 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
4 ms |
5028 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
5024 KB |
Output is correct |
14 |
Correct |
4 ms |
5020 KB |
Output is correct |
15 |
Correct |
4 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
5020 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
3 ms |
4948 KB |
Output is correct |
20 |
Correct |
4 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
4948 KB |
Output is correct |
22 |
Correct |
4 ms |
5020 KB |
Output is correct |
23 |
Correct |
3 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Correct |
3 ms |
4948 KB |
Output is correct |
26 |
Correct |
3 ms |
4948 KB |
Output is correct |
27 |
Correct |
3 ms |
4948 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
26 ms |
5072 KB |
Output is correct |
30 |
Correct |
62 ms |
5076 KB |
Output is correct |
31 |
Correct |
77 ms |
5096 KB |
Output is correct |
32 |
Correct |
69 ms |
5084 KB |
Output is correct |
33 |
Correct |
58 ms |
5076 KB |
Output is correct |
34 |
Correct |
67 ms |
5108 KB |
Output is correct |
35 |
Correct |
73 ms |
5100 KB |
Output is correct |
36 |
Correct |
55 ms |
5092 KB |
Output is correct |
37 |
Correct |
86 ms |
5076 KB |
Output is correct |
38 |
Correct |
116 ms |
5076 KB |
Output is correct |
39 |
Correct |
50 ms |
5092 KB |
Output is correct |
40 |
Correct |
55 ms |
5080 KB |
Output is correct |
41 |
Correct |
53 ms |
5076 KB |
Output is correct |
42 |
Correct |
51 ms |
5076 KB |
Output is correct |
43 |
Correct |
68 ms |
5088 KB |
Output is correct |
44 |
Correct |
74 ms |
5032 KB |
Output is correct |
45 |
Correct |
63 ms |
5092 KB |
Output is correct |
46 |
Correct |
73 ms |
5104 KB |
Output is correct |
47 |
Correct |
53 ms |
5076 KB |
Output is correct |
48 |
Correct |
68 ms |
5088 KB |
Output is correct |
49 |
Correct |
72 ms |
5088 KB |
Output is correct |
50 |
Correct |
75 ms |
5088 KB |
Output is correct |
51 |
Correct |
68 ms |
5076 KB |
Output is correct |
52 |
Correct |
64 ms |
5084 KB |
Output is correct |
53 |
Correct |
67 ms |
5028 KB |
Output is correct |
54 |
Correct |
87 ms |
5076 KB |
Output is correct |
55 |
Correct |
691 ms |
12332 KB |
Output is correct |
56 |
Correct |
1550 ms |
12996 KB |
Output is correct |
57 |
Correct |
219 ms |
13544 KB |
Output is correct |
58 |
Correct |
168 ms |
12352 KB |
Output is correct |
59 |
Correct |
180 ms |
12364 KB |
Output is correct |
60 |
Correct |
409 ms |
11404 KB |
Output is correct |
61 |
Correct |
484 ms |
11836 KB |
Output is correct |
62 |
Correct |
927 ms |
13252 KB |
Output is correct |
63 |
Correct |
832 ms |
12352 KB |
Output is correct |
64 |
Correct |
765 ms |
13416 KB |
Output is correct |
65 |
Correct |
707 ms |
11280 KB |
Output is correct |
66 |
Correct |
441 ms |
11876 KB |
Output is correct |
67 |
Correct |
771 ms |
12832 KB |
Output is correct |
68 |
Correct |
908 ms |
13636 KB |
Output is correct |
69 |
Correct |
687 ms |
12608 KB |
Output is correct |
70 |
Correct |
1517 ms |
13512 KB |
Output is correct |
71 |
Correct |
1398 ms |
13824 KB |
Output is correct |
72 |
Correct |
137 ms |
12820 KB |
Output is correct |
73 |
Correct |
148 ms |
12836 KB |
Output is correct |
74 |
Correct |
532 ms |
12352 KB |
Output is correct |
75 |
Correct |
933 ms |
13632 KB |
Output is correct |
76 |
Correct |
848 ms |
12368 KB |
Output is correct |
77 |
Correct |
866 ms |
13204 KB |
Output is correct |
78 |
Correct |
802 ms |
13840 KB |
Output is correct |
79 |
Correct |
596 ms |
11584 KB |
Output is correct |
80 |
Correct |
544 ms |
12372 KB |
Output is correct |
81 |
Correct |
863 ms |
13204 KB |
Output is correct |
82 |
Correct |
975 ms |
13896 KB |
Output is correct |
83 |
Incorrect |
632 ms |
10092 KB |
Output isn't correct |
84 |
Halted |
0 ms |
0 KB |
- |