# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1050409 |
2024-08-09T09:13:29 Z |
duckindog |
Joker (BOI20_joker) |
C++17 |
|
161 ms |
604 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 10;
int n, m, q;
vector<pair<int, int>> ad[N];
int co[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
int u, v; cin >> u >> v;
ad[u].push_back({v, i});
ad[v].push_back({u, i});
}
auto color = [&](int st, int l, int r) {
bool ret = false;
co[st] = 1;
queue<int> q({st});
while (q.size()) {
auto u = q.front(); q.pop();
for (const auto& [v, id] : ad[u]) {
if (l <= id && id <= r) continue;
if (co[v] == co[u]) return true;
if (co[v]) continue;
co[v] = co[u] ^ 3;
q.push(v);
}
}
return false;
};
auto cal = [&](int l, int r) {
memset(co, 0, sizeof co);
for (int i = 1; i <= n; ++i) if (!co[i] && color(i, l, r)) return true;
return false;
};
if (n <= 2000 && q <= 2000) {
while (q--) {
int l, r; cin >> l >> r;
cout << (cal(l, r) ? "YES" : "NO") << "\n";
}
return 0;
}
int l = 1, r = m, ma = -1;
while (l <= r) {
int mid = l + r >> 1;
if (cal(l, mid)) l = (ma = mid) + 1;
else r = mid - 1;
}
while (q--) {
int l, r; cin >> l >> r;
cout << (r <= ma ? "YES" : "NO") << "\n";
}
}
Compilation message
Joker.cpp: In lambda function:
Joker.cpp:21:10: warning: unused variable 'ret' [-Wunused-variable]
21 | bool ret = false;
| ^~~
Joker.cpp: In function 'int32_t main()':
Joker.cpp:52:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
52 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
508 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 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 |
344 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 |
508 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 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 |
161 ms |
348 KB |
Output is correct |
30 |
Correct |
77 ms |
344 KB |
Output is correct |
31 |
Correct |
48 ms |
344 KB |
Output is correct |
32 |
Correct |
20 ms |
348 KB |
Output is correct |
33 |
Correct |
8 ms |
348 KB |
Output is correct |
34 |
Correct |
53 ms |
580 KB |
Output is correct |
35 |
Correct |
83 ms |
584 KB |
Output is correct |
36 |
Correct |
23 ms |
596 KB |
Output is correct |
37 |
Correct |
86 ms |
348 KB |
Output is correct |
38 |
Correct |
51 ms |
344 KB |
Output is correct |
39 |
Correct |
88 ms |
348 KB |
Output is correct |
40 |
Correct |
29 ms |
348 KB |
Output is correct |
41 |
Correct |
28 ms |
592 KB |
Output is correct |
42 |
Correct |
32 ms |
348 KB |
Output is correct |
43 |
Correct |
2 ms |
344 KB |
Output is correct |
44 |
Correct |
3 ms |
348 KB |
Output is correct |
45 |
Correct |
5 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
348 KB |
Output is correct |
47 |
Correct |
22 ms |
348 KB |
Output is correct |
48 |
Correct |
24 ms |
576 KB |
Output is correct |
49 |
Correct |
48 ms |
588 KB |
Output is correct |
50 |
Correct |
71 ms |
344 KB |
Output is correct |
51 |
Correct |
22 ms |
344 KB |
Output is correct |
52 |
Correct |
32 ms |
348 KB |
Output is correct |
53 |
Correct |
48 ms |
348 KB |
Output is correct |
54 |
Correct |
75 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
508 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 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 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
508 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 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 |
161 ms |
348 KB |
Output is correct |
30 |
Correct |
77 ms |
344 KB |
Output is correct |
31 |
Correct |
48 ms |
344 KB |
Output is correct |
32 |
Correct |
20 ms |
348 KB |
Output is correct |
33 |
Correct |
8 ms |
348 KB |
Output is correct |
34 |
Correct |
53 ms |
580 KB |
Output is correct |
35 |
Correct |
83 ms |
584 KB |
Output is correct |
36 |
Correct |
23 ms |
596 KB |
Output is correct |
37 |
Correct |
86 ms |
348 KB |
Output is correct |
38 |
Correct |
51 ms |
344 KB |
Output is correct |
39 |
Correct |
88 ms |
348 KB |
Output is correct |
40 |
Correct |
29 ms |
348 KB |
Output is correct |
41 |
Correct |
28 ms |
592 KB |
Output is correct |
42 |
Correct |
32 ms |
348 KB |
Output is correct |
43 |
Correct |
2 ms |
344 KB |
Output is correct |
44 |
Correct |
3 ms |
348 KB |
Output is correct |
45 |
Correct |
5 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
348 KB |
Output is correct |
47 |
Correct |
22 ms |
348 KB |
Output is correct |
48 |
Correct |
24 ms |
576 KB |
Output is correct |
49 |
Correct |
48 ms |
588 KB |
Output is correct |
50 |
Correct |
71 ms |
344 KB |
Output is correct |
51 |
Correct |
22 ms |
344 KB |
Output is correct |
52 |
Correct |
32 ms |
348 KB |
Output is correct |
53 |
Correct |
48 ms |
348 KB |
Output is correct |
54 |
Correct |
75 ms |
344 KB |
Output is correct |
55 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
508 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 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 |
161 ms |
348 KB |
Output is correct |
30 |
Correct |
77 ms |
344 KB |
Output is correct |
31 |
Correct |
48 ms |
344 KB |
Output is correct |
32 |
Correct |
20 ms |
348 KB |
Output is correct |
33 |
Correct |
8 ms |
348 KB |
Output is correct |
34 |
Correct |
53 ms |
580 KB |
Output is correct |
35 |
Correct |
83 ms |
584 KB |
Output is correct |
36 |
Correct |
23 ms |
596 KB |
Output is correct |
37 |
Correct |
86 ms |
348 KB |
Output is correct |
38 |
Correct |
51 ms |
344 KB |
Output is correct |
39 |
Correct |
88 ms |
348 KB |
Output is correct |
40 |
Correct |
29 ms |
348 KB |
Output is correct |
41 |
Correct |
28 ms |
592 KB |
Output is correct |
42 |
Correct |
32 ms |
348 KB |
Output is correct |
43 |
Correct |
2 ms |
344 KB |
Output is correct |
44 |
Correct |
3 ms |
348 KB |
Output is correct |
45 |
Correct |
5 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
348 KB |
Output is correct |
47 |
Correct |
22 ms |
348 KB |
Output is correct |
48 |
Correct |
24 ms |
576 KB |
Output is correct |
49 |
Correct |
48 ms |
588 KB |
Output is correct |
50 |
Correct |
71 ms |
344 KB |
Output is correct |
51 |
Correct |
22 ms |
344 KB |
Output is correct |
52 |
Correct |
32 ms |
348 KB |
Output is correct |
53 |
Correct |
48 ms |
348 KB |
Output is correct |
54 |
Correct |
75 ms |
344 KB |
Output is correct |
55 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
56 |
Halted |
0 ms |
0 KB |
- |