# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
877225 |
2023-11-23T04:05:11 Z |
CDuong |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
3016 KB |
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname "NOHOME"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;
struct DisjointSetUnion01 {
vector<int> lab, val;
DisjointSetUnion01(int n) : lab(n + 1, -1), val(n + 1, 0) {}
pair<int, int> root(int v) {
if (lab[v] < 0) return {v, val[v]};
auto cpar = root(lab[v]);
lab[v] = cpar.ff, val[v] ^= cpar.ss;
return {lab[v], val[v]};
}
bool merge(int u, int v, int edge_val) {
auto rootu = root(u);
auto rootv = root(v);
if (rootu.ff != rootv.ff) {
if (-lab[rootu.ff] < -lab[rootv.ff])
swap(u, v), swap(rootu, rootv);
lab[rootu.ff] += lab[rootv.ff];
lab[rootv.ff] = rootu.ff;
val[rootv.ff] = rootu.ss ^ rootv.ss ^ edge_val;
return true;
}
return (rootu.ss ^ rootv.ss ^ edge_val ^ 1);
}
};
int n, m, q;
vector<pair<int, int>> edges;
void solve() {
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
int u, v;
cin >> u >> v;
edges.emplace_back(u, v);
}
for (int i = 1; i <= q; ++i) {
int l, r; cin >> l >> r;
bool flag = true;
DisjointSetUnion01 dsu(n + 1);
for (int i = 0; i < l - 1; ++i) flag &= dsu.merge(edges[i].ff, edges[i].ss, 1);
for (int i = r; i < m; ++i) flag &= dsu.merge(edges[i].ff, edges[i].ss, 1);
cout << (flag ? "NO" : "YES") << "\n";
}
}
signed main() {
#ifndef CDuongg
if(fopen(taskname".inp", "r"))
assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
freopen("bai3.inp", "r", stdin);
freopen("bai3.out", "w", stdout);
auto start = chrono::high_resolution_clock::now();
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
while(t--) solve();
#ifdef CDuongg
auto end = chrono::high_resolution_clock::now();
cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
388 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
388 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
10 ms |
348 KB |
Output is correct |
30 |
Correct |
20 ms |
500 KB |
Output is correct |
31 |
Correct |
21 ms |
348 KB |
Output is correct |
32 |
Correct |
18 ms |
344 KB |
Output is correct |
33 |
Correct |
15 ms |
492 KB |
Output is correct |
34 |
Correct |
20 ms |
348 KB |
Output is correct |
35 |
Correct |
23 ms |
348 KB |
Output is correct |
36 |
Correct |
14 ms |
492 KB |
Output is correct |
37 |
Correct |
18 ms |
496 KB |
Output is correct |
38 |
Correct |
21 ms |
348 KB |
Output is correct |
39 |
Correct |
14 ms |
348 KB |
Output is correct |
40 |
Correct |
17 ms |
348 KB |
Output is correct |
41 |
Correct |
16 ms |
488 KB |
Output is correct |
42 |
Correct |
16 ms |
348 KB |
Output is correct |
43 |
Correct |
24 ms |
492 KB |
Output is correct |
44 |
Correct |
26 ms |
488 KB |
Output is correct |
45 |
Correct |
28 ms |
488 KB |
Output is correct |
46 |
Correct |
27 ms |
348 KB |
Output is correct |
47 |
Correct |
17 ms |
348 KB |
Output is correct |
48 |
Correct |
19 ms |
488 KB |
Output is correct |
49 |
Correct |
20 ms |
348 KB |
Output is correct |
50 |
Correct |
20 ms |
344 KB |
Output is correct |
51 |
Correct |
16 ms |
348 KB |
Output is correct |
52 |
Correct |
18 ms |
348 KB |
Output is correct |
53 |
Correct |
20 ms |
348 KB |
Output is correct |
54 |
Correct |
25 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2015 ms |
3012 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
388 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Execution timed out |
2015 ms |
3012 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
388 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
10 ms |
348 KB |
Output is correct |
30 |
Correct |
20 ms |
500 KB |
Output is correct |
31 |
Correct |
21 ms |
348 KB |
Output is correct |
32 |
Correct |
18 ms |
344 KB |
Output is correct |
33 |
Correct |
15 ms |
492 KB |
Output is correct |
34 |
Correct |
20 ms |
348 KB |
Output is correct |
35 |
Correct |
23 ms |
348 KB |
Output is correct |
36 |
Correct |
14 ms |
492 KB |
Output is correct |
37 |
Correct |
18 ms |
496 KB |
Output is correct |
38 |
Correct |
21 ms |
348 KB |
Output is correct |
39 |
Correct |
14 ms |
348 KB |
Output is correct |
40 |
Correct |
17 ms |
348 KB |
Output is correct |
41 |
Correct |
16 ms |
488 KB |
Output is correct |
42 |
Correct |
16 ms |
348 KB |
Output is correct |
43 |
Correct |
24 ms |
492 KB |
Output is correct |
44 |
Correct |
26 ms |
488 KB |
Output is correct |
45 |
Correct |
28 ms |
488 KB |
Output is correct |
46 |
Correct |
27 ms |
348 KB |
Output is correct |
47 |
Correct |
17 ms |
348 KB |
Output is correct |
48 |
Correct |
19 ms |
488 KB |
Output is correct |
49 |
Correct |
20 ms |
348 KB |
Output is correct |
50 |
Correct |
20 ms |
344 KB |
Output is correct |
51 |
Correct |
16 ms |
348 KB |
Output is correct |
52 |
Correct |
18 ms |
348 KB |
Output is correct |
53 |
Correct |
20 ms |
348 KB |
Output is correct |
54 |
Correct |
25 ms |
496 KB |
Output is correct |
55 |
Execution timed out |
2033 ms |
3016 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
388 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
10 ms |
348 KB |
Output is correct |
30 |
Correct |
20 ms |
500 KB |
Output is correct |
31 |
Correct |
21 ms |
348 KB |
Output is correct |
32 |
Correct |
18 ms |
344 KB |
Output is correct |
33 |
Correct |
15 ms |
492 KB |
Output is correct |
34 |
Correct |
20 ms |
348 KB |
Output is correct |
35 |
Correct |
23 ms |
348 KB |
Output is correct |
36 |
Correct |
14 ms |
492 KB |
Output is correct |
37 |
Correct |
18 ms |
496 KB |
Output is correct |
38 |
Correct |
21 ms |
348 KB |
Output is correct |
39 |
Correct |
14 ms |
348 KB |
Output is correct |
40 |
Correct |
17 ms |
348 KB |
Output is correct |
41 |
Correct |
16 ms |
488 KB |
Output is correct |
42 |
Correct |
16 ms |
348 KB |
Output is correct |
43 |
Correct |
24 ms |
492 KB |
Output is correct |
44 |
Correct |
26 ms |
488 KB |
Output is correct |
45 |
Correct |
28 ms |
488 KB |
Output is correct |
46 |
Correct |
27 ms |
348 KB |
Output is correct |
47 |
Correct |
17 ms |
348 KB |
Output is correct |
48 |
Correct |
19 ms |
488 KB |
Output is correct |
49 |
Correct |
20 ms |
348 KB |
Output is correct |
50 |
Correct |
20 ms |
344 KB |
Output is correct |
51 |
Correct |
16 ms |
348 KB |
Output is correct |
52 |
Correct |
18 ms |
348 KB |
Output is correct |
53 |
Correct |
20 ms |
348 KB |
Output is correct |
54 |
Correct |
25 ms |
496 KB |
Output is correct |
55 |
Execution timed out |
2015 ms |
3012 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |