# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
858298 |
2023-10-08T03:45:49 Z |
Trisanu_Das |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
26784 KB |
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
vector<pair<int, int> > arr[200005];
int color[200005], ans[200005], a[200005], b[200005], n, m, q;
int dfs(int u, int c) {
if(color[u]) {
if(c == color[u]) return 0;
else return 1;
}
color[u] = c;
for(auto v : adj[u]) if(dfs(v, 3 - c)) return 1;
return 0;
}
bool check(int l, int r) {
memset(color, 0, sizeof color);
for(int i = 1; i <= n; i++) adj[i].clear();
for(int i = 0; i < l; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]);
for(int i = r + 1; i < m; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]);
for(int i = 0; i < n; i++) if(!color[i]) if(dfs(i, 1)) return 1;
return 0;
}
int main() {
cin.sync_with_stdio(false); cin.tie(NULL);
cin >> n >> m >> q;
for(int i = 0; i < m; i++) cin >> a[i] >> b[i];
for(int e = 0; e < q; e++) {
int l, r;
cin >> l >> r;
arr[l - 1].push_back({r - 1, e});
}
for(int i = 0; i < m; i++) {
sort(arr[i].begin(), arr[i].end());
int l = 0, r = arr[i].size();
while(l < r) {
int mid = l + r >> 1;
if(check(i, arr[i][mid].first)) l = mid + 1;
else r = mid;
}
for(int j = 0; j < l; j++) ans[arr[i][j].second] = 1;
for(int j = l; j < arr[i].size(); j++) ans[arr[i][j].second] = 0;
}
for(int i = 0; i < q; i++) cout << (ans[i] ? "YES\n":"NO\n");
}
Compilation message
Joker.cpp: In function 'int main()':
Joker.cpp:40:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
40 | int mid = l + r >> 1;
| ~~^~~
Joker.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int j = l; j < arr[i].size(); j++) ans[arr[i][j].second] = 0;
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
3 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
4 ms |
12804 KB |
Output is correct |
8 |
Correct |
4 ms |
12648 KB |
Output is correct |
9 |
Correct |
4 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12636 KB |
Output is correct |
11 |
Correct |
5 ms |
12636 KB |
Output is correct |
12 |
Correct |
6 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
5 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12824 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
4 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12636 KB |
Output is correct |
20 |
Correct |
4 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
4 ms |
12636 KB |
Output is correct |
23 |
Correct |
4 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12808 KB |
Output is correct |
26 |
Correct |
4 ms |
12816 KB |
Output is correct |
27 |
Correct |
4 ms |
12636 KB |
Output is correct |
28 |
Correct |
5 ms |
12820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
3 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
4 ms |
12804 KB |
Output is correct |
8 |
Correct |
4 ms |
12648 KB |
Output is correct |
9 |
Correct |
4 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12636 KB |
Output is correct |
11 |
Correct |
5 ms |
12636 KB |
Output is correct |
12 |
Correct |
6 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
5 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12824 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
4 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12636 KB |
Output is correct |
20 |
Correct |
4 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
4 ms |
12636 KB |
Output is correct |
23 |
Correct |
4 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12808 KB |
Output is correct |
26 |
Correct |
4 ms |
12816 KB |
Output is correct |
27 |
Correct |
4 ms |
12636 KB |
Output is correct |
28 |
Correct |
5 ms |
12820 KB |
Output is correct |
29 |
Correct |
56 ms |
12632 KB |
Output is correct |
30 |
Correct |
48 ms |
12892 KB |
Output is correct |
31 |
Correct |
41 ms |
12892 KB |
Output is correct |
32 |
Correct |
31 ms |
12812 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
48 ms |
13148 KB |
Output is correct |
35 |
Correct |
53 ms |
12892 KB |
Output is correct |
36 |
Correct |
37 ms |
12888 KB |
Output is correct |
37 |
Correct |
67 ms |
12892 KB |
Output is correct |
38 |
Correct |
71 ms |
12892 KB |
Output is correct |
39 |
Correct |
52 ms |
12892 KB |
Output is correct |
40 |
Correct |
39 ms |
12888 KB |
Output is correct |
41 |
Correct |
36 ms |
12892 KB |
Output is correct |
42 |
Correct |
36 ms |
12892 KB |
Output is correct |
43 |
Correct |
29 ms |
13140 KB |
Output is correct |
44 |
Correct |
30 ms |
12892 KB |
Output is correct |
45 |
Correct |
33 ms |
12912 KB |
Output is correct |
46 |
Correct |
38 ms |
12892 KB |
Output is correct |
47 |
Correct |
39 ms |
13148 KB |
Output is correct |
48 |
Correct |
37 ms |
12892 KB |
Output is correct |
49 |
Correct |
42 ms |
12892 KB |
Output is correct |
50 |
Correct |
48 ms |
12860 KB |
Output is correct |
51 |
Correct |
33 ms |
12892 KB |
Output is correct |
52 |
Correct |
36 ms |
12720 KB |
Output is correct |
53 |
Correct |
40 ms |
12892 KB |
Output is correct |
54 |
Correct |
50 ms |
12892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
114 ms |
22980 KB |
Output is correct |
4 |
Correct |
197 ms |
26564 KB |
Output is correct |
5 |
Correct |
95 ms |
20680 KB |
Output is correct |
6 |
Correct |
119 ms |
23072 KB |
Output is correct |
7 |
Correct |
118 ms |
22472 KB |
Output is correct |
8 |
Correct |
111 ms |
23496 KB |
Output is correct |
9 |
Correct |
127 ms |
23944 KB |
Output is correct |
10 |
Correct |
139 ms |
24716 KB |
Output is correct |
11 |
Correct |
122 ms |
22200 KB |
Output is correct |
12 |
Correct |
146 ms |
23312 KB |
Output is correct |
13 |
Correct |
98 ms |
21768 KB |
Output is correct |
14 |
Correct |
125 ms |
22980 KB |
Output is correct |
15 |
Correct |
142 ms |
23236 KB |
Output is correct |
16 |
Correct |
160 ms |
23692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
3 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
4 ms |
12804 KB |
Output is correct |
8 |
Correct |
4 ms |
12648 KB |
Output is correct |
9 |
Correct |
4 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12636 KB |
Output is correct |
11 |
Correct |
5 ms |
12636 KB |
Output is correct |
12 |
Correct |
6 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
5 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12824 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
4 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12636 KB |
Output is correct |
20 |
Correct |
4 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
4 ms |
12636 KB |
Output is correct |
23 |
Correct |
4 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12808 KB |
Output is correct |
26 |
Correct |
4 ms |
12816 KB |
Output is correct |
27 |
Correct |
4 ms |
12636 KB |
Output is correct |
28 |
Correct |
5 ms |
12820 KB |
Output is correct |
29 |
Correct |
114 ms |
22980 KB |
Output is correct |
30 |
Correct |
197 ms |
26564 KB |
Output is correct |
31 |
Correct |
95 ms |
20680 KB |
Output is correct |
32 |
Correct |
119 ms |
23072 KB |
Output is correct |
33 |
Correct |
118 ms |
22472 KB |
Output is correct |
34 |
Correct |
111 ms |
23496 KB |
Output is correct |
35 |
Correct |
127 ms |
23944 KB |
Output is correct |
36 |
Correct |
139 ms |
24716 KB |
Output is correct |
37 |
Correct |
122 ms |
22200 KB |
Output is correct |
38 |
Correct |
146 ms |
23312 KB |
Output is correct |
39 |
Correct |
98 ms |
21768 KB |
Output is correct |
40 |
Correct |
125 ms |
22980 KB |
Output is correct |
41 |
Correct |
142 ms |
23236 KB |
Output is correct |
42 |
Correct |
160 ms |
23692 KB |
Output is correct |
43 |
Execution timed out |
2011 ms |
26784 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
3 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
4 ms |
12804 KB |
Output is correct |
8 |
Correct |
4 ms |
12648 KB |
Output is correct |
9 |
Correct |
4 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12636 KB |
Output is correct |
11 |
Correct |
5 ms |
12636 KB |
Output is correct |
12 |
Correct |
6 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
5 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12824 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
4 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12636 KB |
Output is correct |
20 |
Correct |
4 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
4 ms |
12636 KB |
Output is correct |
23 |
Correct |
4 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12808 KB |
Output is correct |
26 |
Correct |
4 ms |
12816 KB |
Output is correct |
27 |
Correct |
4 ms |
12636 KB |
Output is correct |
28 |
Correct |
5 ms |
12820 KB |
Output is correct |
29 |
Correct |
56 ms |
12632 KB |
Output is correct |
30 |
Correct |
48 ms |
12892 KB |
Output is correct |
31 |
Correct |
41 ms |
12892 KB |
Output is correct |
32 |
Correct |
31 ms |
12812 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
48 ms |
13148 KB |
Output is correct |
35 |
Correct |
53 ms |
12892 KB |
Output is correct |
36 |
Correct |
37 ms |
12888 KB |
Output is correct |
37 |
Correct |
67 ms |
12892 KB |
Output is correct |
38 |
Correct |
71 ms |
12892 KB |
Output is correct |
39 |
Correct |
52 ms |
12892 KB |
Output is correct |
40 |
Correct |
39 ms |
12888 KB |
Output is correct |
41 |
Correct |
36 ms |
12892 KB |
Output is correct |
42 |
Correct |
36 ms |
12892 KB |
Output is correct |
43 |
Correct |
29 ms |
13140 KB |
Output is correct |
44 |
Correct |
30 ms |
12892 KB |
Output is correct |
45 |
Correct |
33 ms |
12912 KB |
Output is correct |
46 |
Correct |
38 ms |
12892 KB |
Output is correct |
47 |
Correct |
39 ms |
13148 KB |
Output is correct |
48 |
Correct |
37 ms |
12892 KB |
Output is correct |
49 |
Correct |
42 ms |
12892 KB |
Output is correct |
50 |
Correct |
48 ms |
12860 KB |
Output is correct |
51 |
Correct |
33 ms |
12892 KB |
Output is correct |
52 |
Correct |
36 ms |
12720 KB |
Output is correct |
53 |
Correct |
40 ms |
12892 KB |
Output is correct |
54 |
Correct |
50 ms |
12892 KB |
Output is correct |
55 |
Execution timed out |
2043 ms |
19572 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
3 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
3 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
4 ms |
12804 KB |
Output is correct |
8 |
Correct |
4 ms |
12648 KB |
Output is correct |
9 |
Correct |
4 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12636 KB |
Output is correct |
11 |
Correct |
5 ms |
12636 KB |
Output is correct |
12 |
Correct |
6 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
5 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12824 KB |
Output is correct |
16 |
Correct |
4 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
4 ms |
12636 KB |
Output is correct |
19 |
Correct |
4 ms |
12636 KB |
Output is correct |
20 |
Correct |
4 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
4 ms |
12636 KB |
Output is correct |
23 |
Correct |
4 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12808 KB |
Output is correct |
26 |
Correct |
4 ms |
12816 KB |
Output is correct |
27 |
Correct |
4 ms |
12636 KB |
Output is correct |
28 |
Correct |
5 ms |
12820 KB |
Output is correct |
29 |
Correct |
56 ms |
12632 KB |
Output is correct |
30 |
Correct |
48 ms |
12892 KB |
Output is correct |
31 |
Correct |
41 ms |
12892 KB |
Output is correct |
32 |
Correct |
31 ms |
12812 KB |
Output is correct |
33 |
Correct |
29 ms |
12892 KB |
Output is correct |
34 |
Correct |
48 ms |
13148 KB |
Output is correct |
35 |
Correct |
53 ms |
12892 KB |
Output is correct |
36 |
Correct |
37 ms |
12888 KB |
Output is correct |
37 |
Correct |
67 ms |
12892 KB |
Output is correct |
38 |
Correct |
71 ms |
12892 KB |
Output is correct |
39 |
Correct |
52 ms |
12892 KB |
Output is correct |
40 |
Correct |
39 ms |
12888 KB |
Output is correct |
41 |
Correct |
36 ms |
12892 KB |
Output is correct |
42 |
Correct |
36 ms |
12892 KB |
Output is correct |
43 |
Correct |
29 ms |
13140 KB |
Output is correct |
44 |
Correct |
30 ms |
12892 KB |
Output is correct |
45 |
Correct |
33 ms |
12912 KB |
Output is correct |
46 |
Correct |
38 ms |
12892 KB |
Output is correct |
47 |
Correct |
39 ms |
13148 KB |
Output is correct |
48 |
Correct |
37 ms |
12892 KB |
Output is correct |
49 |
Correct |
42 ms |
12892 KB |
Output is correct |
50 |
Correct |
48 ms |
12860 KB |
Output is correct |
51 |
Correct |
33 ms |
12892 KB |
Output is correct |
52 |
Correct |
36 ms |
12720 KB |
Output is correct |
53 |
Correct |
40 ms |
12892 KB |
Output is correct |
54 |
Correct |
50 ms |
12892 KB |
Output is correct |
55 |
Correct |
114 ms |
22980 KB |
Output is correct |
56 |
Correct |
197 ms |
26564 KB |
Output is correct |
57 |
Correct |
95 ms |
20680 KB |
Output is correct |
58 |
Correct |
119 ms |
23072 KB |
Output is correct |
59 |
Correct |
118 ms |
22472 KB |
Output is correct |
60 |
Correct |
111 ms |
23496 KB |
Output is correct |
61 |
Correct |
127 ms |
23944 KB |
Output is correct |
62 |
Correct |
139 ms |
24716 KB |
Output is correct |
63 |
Correct |
122 ms |
22200 KB |
Output is correct |
64 |
Correct |
146 ms |
23312 KB |
Output is correct |
65 |
Correct |
98 ms |
21768 KB |
Output is correct |
66 |
Correct |
125 ms |
22980 KB |
Output is correct |
67 |
Correct |
142 ms |
23236 KB |
Output is correct |
68 |
Correct |
160 ms |
23692 KB |
Output is correct |
69 |
Execution timed out |
2011 ms |
26784 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |