# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
759313 |
2023-06-16T05:57:35 Z |
vjudge1 |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
22792 KB |
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define N 200100
vector<int> adj[N];
vector<pair<int, int>> arr[N];
int color[N], ans[N], a[N], b[N], n, m, q;
int dfs(int x, int col) {
if(color[x]) {
if(col==color[x]) return 0;
else return 1;
}
color[x] = col;
for(auto i: adj[x])
if(dfs(i, 3-col))
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(nullptr);
cin >> n >> m >> q;
for(int i = 0; i < m; i++)
cin >> a[i] >> b[i];
for(int i = 0; i < q; ++i) {
int l, r;
cin >> l >> r;
arr[l-1].push_back({r-1,i});
}
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:48:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
48 | int mid = l+r>>1;
| ~^~
Joker.cpp:57: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]
57 | for(int j = l; j < arr[i].size(); ++j)
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
5 ms |
10452 KB |
Output is correct |
4 |
Correct |
5 ms |
10424 KB |
Output is correct |
5 |
Correct |
5 ms |
10452 KB |
Output is correct |
6 |
Correct |
5 ms |
10452 KB |
Output is correct |
7 |
Correct |
7 ms |
10452 KB |
Output is correct |
8 |
Correct |
7 ms |
10532 KB |
Output is correct |
9 |
Correct |
7 ms |
10452 KB |
Output is correct |
10 |
Correct |
7 ms |
10452 KB |
Output is correct |
11 |
Correct |
7 ms |
10452 KB |
Output is correct |
12 |
Correct |
7 ms |
10452 KB |
Output is correct |
13 |
Correct |
7 ms |
10532 KB |
Output is correct |
14 |
Correct |
8 ms |
10452 KB |
Output is correct |
15 |
Correct |
7 ms |
10452 KB |
Output is correct |
16 |
Correct |
7 ms |
10536 KB |
Output is correct |
17 |
Correct |
8 ms |
10452 KB |
Output is correct |
18 |
Correct |
8 ms |
10452 KB |
Output is correct |
19 |
Correct |
8 ms |
10456 KB |
Output is correct |
20 |
Correct |
9 ms |
10452 KB |
Output is correct |
21 |
Correct |
7 ms |
10452 KB |
Output is correct |
22 |
Correct |
7 ms |
10532 KB |
Output is correct |
23 |
Correct |
7 ms |
10452 KB |
Output is correct |
24 |
Correct |
7 ms |
10452 KB |
Output is correct |
25 |
Correct |
7 ms |
10528 KB |
Output is correct |
26 |
Correct |
7 ms |
10452 KB |
Output is correct |
27 |
Correct |
7 ms |
10428 KB |
Output is correct |
28 |
Correct |
7 ms |
10452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
5 ms |
10452 KB |
Output is correct |
4 |
Correct |
5 ms |
10424 KB |
Output is correct |
5 |
Correct |
5 ms |
10452 KB |
Output is correct |
6 |
Correct |
5 ms |
10452 KB |
Output is correct |
7 |
Correct |
7 ms |
10452 KB |
Output is correct |
8 |
Correct |
7 ms |
10532 KB |
Output is correct |
9 |
Correct |
7 ms |
10452 KB |
Output is correct |
10 |
Correct |
7 ms |
10452 KB |
Output is correct |
11 |
Correct |
7 ms |
10452 KB |
Output is correct |
12 |
Correct |
7 ms |
10452 KB |
Output is correct |
13 |
Correct |
7 ms |
10532 KB |
Output is correct |
14 |
Correct |
8 ms |
10452 KB |
Output is correct |
15 |
Correct |
7 ms |
10452 KB |
Output is correct |
16 |
Correct |
7 ms |
10536 KB |
Output is correct |
17 |
Correct |
8 ms |
10452 KB |
Output is correct |
18 |
Correct |
8 ms |
10452 KB |
Output is correct |
19 |
Correct |
8 ms |
10456 KB |
Output is correct |
20 |
Correct |
9 ms |
10452 KB |
Output is correct |
21 |
Correct |
7 ms |
10452 KB |
Output is correct |
22 |
Correct |
7 ms |
10532 KB |
Output is correct |
23 |
Correct |
7 ms |
10452 KB |
Output is correct |
24 |
Correct |
7 ms |
10452 KB |
Output is correct |
25 |
Correct |
7 ms |
10528 KB |
Output is correct |
26 |
Correct |
7 ms |
10452 KB |
Output is correct |
27 |
Correct |
7 ms |
10428 KB |
Output is correct |
28 |
Correct |
7 ms |
10452 KB |
Output is correct |
29 |
Correct |
64 ms |
10596 KB |
Output is correct |
30 |
Correct |
52 ms |
10632 KB |
Output is correct |
31 |
Correct |
45 ms |
10628 KB |
Output is correct |
32 |
Correct |
35 ms |
10616 KB |
Output is correct |
33 |
Correct |
30 ms |
10580 KB |
Output is correct |
34 |
Correct |
48 ms |
10640 KB |
Output is correct |
35 |
Correct |
57 ms |
10580 KB |
Output is correct |
36 |
Correct |
41 ms |
10616 KB |
Output is correct |
37 |
Correct |
73 ms |
10652 KB |
Output is correct |
38 |
Correct |
78 ms |
10644 KB |
Output is correct |
39 |
Correct |
57 ms |
10652 KB |
Output is correct |
40 |
Correct |
41 ms |
10580 KB |
Output is correct |
41 |
Correct |
44 ms |
10748 KB |
Output is correct |
42 |
Correct |
40 ms |
10636 KB |
Output is correct |
43 |
Correct |
33 ms |
10632 KB |
Output is correct |
44 |
Correct |
33 ms |
10580 KB |
Output is correct |
45 |
Correct |
36 ms |
10640 KB |
Output is correct |
46 |
Correct |
41 ms |
10656 KB |
Output is correct |
47 |
Correct |
43 ms |
10636 KB |
Output is correct |
48 |
Correct |
47 ms |
10628 KB |
Output is correct |
49 |
Correct |
51 ms |
10636 KB |
Output is correct |
50 |
Correct |
54 ms |
10628 KB |
Output is correct |
51 |
Correct |
37 ms |
10580 KB |
Output is correct |
52 |
Correct |
39 ms |
10580 KB |
Output is correct |
53 |
Correct |
44 ms |
10628 KB |
Output is correct |
54 |
Correct |
53 ms |
10632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
120 ms |
21284 KB |
Output is correct |
4 |
Correct |
262 ms |
22792 KB |
Output is correct |
5 |
Correct |
101 ms |
16484 KB |
Output is correct |
6 |
Correct |
127 ms |
19104 KB |
Output is correct |
7 |
Correct |
122 ms |
18296 KB |
Output is correct |
8 |
Correct |
123 ms |
20152 KB |
Output is correct |
9 |
Correct |
202 ms |
20544 KB |
Output is correct |
10 |
Correct |
167 ms |
20800 KB |
Output is correct |
11 |
Correct |
142 ms |
18228 KB |
Output is correct |
12 |
Correct |
164 ms |
19080 KB |
Output is correct |
13 |
Correct |
117 ms |
17592 KB |
Output is correct |
14 |
Correct |
133 ms |
19032 KB |
Output is correct |
15 |
Correct |
155 ms |
19304 KB |
Output is correct |
16 |
Correct |
217 ms |
19308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
5 ms |
10452 KB |
Output is correct |
4 |
Correct |
5 ms |
10424 KB |
Output is correct |
5 |
Correct |
5 ms |
10452 KB |
Output is correct |
6 |
Correct |
5 ms |
10452 KB |
Output is correct |
7 |
Correct |
7 ms |
10452 KB |
Output is correct |
8 |
Correct |
7 ms |
10532 KB |
Output is correct |
9 |
Correct |
7 ms |
10452 KB |
Output is correct |
10 |
Correct |
7 ms |
10452 KB |
Output is correct |
11 |
Correct |
7 ms |
10452 KB |
Output is correct |
12 |
Correct |
7 ms |
10452 KB |
Output is correct |
13 |
Correct |
7 ms |
10532 KB |
Output is correct |
14 |
Correct |
8 ms |
10452 KB |
Output is correct |
15 |
Correct |
7 ms |
10452 KB |
Output is correct |
16 |
Correct |
7 ms |
10536 KB |
Output is correct |
17 |
Correct |
8 ms |
10452 KB |
Output is correct |
18 |
Correct |
8 ms |
10452 KB |
Output is correct |
19 |
Correct |
8 ms |
10456 KB |
Output is correct |
20 |
Correct |
9 ms |
10452 KB |
Output is correct |
21 |
Correct |
7 ms |
10452 KB |
Output is correct |
22 |
Correct |
7 ms |
10532 KB |
Output is correct |
23 |
Correct |
7 ms |
10452 KB |
Output is correct |
24 |
Correct |
7 ms |
10452 KB |
Output is correct |
25 |
Correct |
7 ms |
10528 KB |
Output is correct |
26 |
Correct |
7 ms |
10452 KB |
Output is correct |
27 |
Correct |
7 ms |
10428 KB |
Output is correct |
28 |
Correct |
7 ms |
10452 KB |
Output is correct |
29 |
Correct |
120 ms |
21284 KB |
Output is correct |
30 |
Correct |
262 ms |
22792 KB |
Output is correct |
31 |
Correct |
101 ms |
16484 KB |
Output is correct |
32 |
Correct |
127 ms |
19104 KB |
Output is correct |
33 |
Correct |
122 ms |
18296 KB |
Output is correct |
34 |
Correct |
123 ms |
20152 KB |
Output is correct |
35 |
Correct |
202 ms |
20544 KB |
Output is correct |
36 |
Correct |
167 ms |
20800 KB |
Output is correct |
37 |
Correct |
142 ms |
18228 KB |
Output is correct |
38 |
Correct |
164 ms |
19080 KB |
Output is correct |
39 |
Correct |
117 ms |
17592 KB |
Output is correct |
40 |
Correct |
133 ms |
19032 KB |
Output is correct |
41 |
Correct |
155 ms |
19304 KB |
Output is correct |
42 |
Correct |
217 ms |
19308 KB |
Output is correct |
43 |
Execution timed out |
2072 ms |
22480 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
5 ms |
10452 KB |
Output is correct |
4 |
Correct |
5 ms |
10424 KB |
Output is correct |
5 |
Correct |
5 ms |
10452 KB |
Output is correct |
6 |
Correct |
5 ms |
10452 KB |
Output is correct |
7 |
Correct |
7 ms |
10452 KB |
Output is correct |
8 |
Correct |
7 ms |
10532 KB |
Output is correct |
9 |
Correct |
7 ms |
10452 KB |
Output is correct |
10 |
Correct |
7 ms |
10452 KB |
Output is correct |
11 |
Correct |
7 ms |
10452 KB |
Output is correct |
12 |
Correct |
7 ms |
10452 KB |
Output is correct |
13 |
Correct |
7 ms |
10532 KB |
Output is correct |
14 |
Correct |
8 ms |
10452 KB |
Output is correct |
15 |
Correct |
7 ms |
10452 KB |
Output is correct |
16 |
Correct |
7 ms |
10536 KB |
Output is correct |
17 |
Correct |
8 ms |
10452 KB |
Output is correct |
18 |
Correct |
8 ms |
10452 KB |
Output is correct |
19 |
Correct |
8 ms |
10456 KB |
Output is correct |
20 |
Correct |
9 ms |
10452 KB |
Output is correct |
21 |
Correct |
7 ms |
10452 KB |
Output is correct |
22 |
Correct |
7 ms |
10532 KB |
Output is correct |
23 |
Correct |
7 ms |
10452 KB |
Output is correct |
24 |
Correct |
7 ms |
10452 KB |
Output is correct |
25 |
Correct |
7 ms |
10528 KB |
Output is correct |
26 |
Correct |
7 ms |
10452 KB |
Output is correct |
27 |
Correct |
7 ms |
10428 KB |
Output is correct |
28 |
Correct |
7 ms |
10452 KB |
Output is correct |
29 |
Correct |
64 ms |
10596 KB |
Output is correct |
30 |
Correct |
52 ms |
10632 KB |
Output is correct |
31 |
Correct |
45 ms |
10628 KB |
Output is correct |
32 |
Correct |
35 ms |
10616 KB |
Output is correct |
33 |
Correct |
30 ms |
10580 KB |
Output is correct |
34 |
Correct |
48 ms |
10640 KB |
Output is correct |
35 |
Correct |
57 ms |
10580 KB |
Output is correct |
36 |
Correct |
41 ms |
10616 KB |
Output is correct |
37 |
Correct |
73 ms |
10652 KB |
Output is correct |
38 |
Correct |
78 ms |
10644 KB |
Output is correct |
39 |
Correct |
57 ms |
10652 KB |
Output is correct |
40 |
Correct |
41 ms |
10580 KB |
Output is correct |
41 |
Correct |
44 ms |
10748 KB |
Output is correct |
42 |
Correct |
40 ms |
10636 KB |
Output is correct |
43 |
Correct |
33 ms |
10632 KB |
Output is correct |
44 |
Correct |
33 ms |
10580 KB |
Output is correct |
45 |
Correct |
36 ms |
10640 KB |
Output is correct |
46 |
Correct |
41 ms |
10656 KB |
Output is correct |
47 |
Correct |
43 ms |
10636 KB |
Output is correct |
48 |
Correct |
47 ms |
10628 KB |
Output is correct |
49 |
Correct |
51 ms |
10636 KB |
Output is correct |
50 |
Correct |
54 ms |
10628 KB |
Output is correct |
51 |
Correct |
37 ms |
10580 KB |
Output is correct |
52 |
Correct |
39 ms |
10580 KB |
Output is correct |
53 |
Correct |
44 ms |
10628 KB |
Output is correct |
54 |
Correct |
53 ms |
10632 KB |
Output is correct |
55 |
Execution timed out |
2079 ms |
18448 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10452 KB |
Output is correct |
2 |
Correct |
5 ms |
10452 KB |
Output is correct |
3 |
Correct |
5 ms |
10452 KB |
Output is correct |
4 |
Correct |
5 ms |
10424 KB |
Output is correct |
5 |
Correct |
5 ms |
10452 KB |
Output is correct |
6 |
Correct |
5 ms |
10452 KB |
Output is correct |
7 |
Correct |
7 ms |
10452 KB |
Output is correct |
8 |
Correct |
7 ms |
10532 KB |
Output is correct |
9 |
Correct |
7 ms |
10452 KB |
Output is correct |
10 |
Correct |
7 ms |
10452 KB |
Output is correct |
11 |
Correct |
7 ms |
10452 KB |
Output is correct |
12 |
Correct |
7 ms |
10452 KB |
Output is correct |
13 |
Correct |
7 ms |
10532 KB |
Output is correct |
14 |
Correct |
8 ms |
10452 KB |
Output is correct |
15 |
Correct |
7 ms |
10452 KB |
Output is correct |
16 |
Correct |
7 ms |
10536 KB |
Output is correct |
17 |
Correct |
8 ms |
10452 KB |
Output is correct |
18 |
Correct |
8 ms |
10452 KB |
Output is correct |
19 |
Correct |
8 ms |
10456 KB |
Output is correct |
20 |
Correct |
9 ms |
10452 KB |
Output is correct |
21 |
Correct |
7 ms |
10452 KB |
Output is correct |
22 |
Correct |
7 ms |
10532 KB |
Output is correct |
23 |
Correct |
7 ms |
10452 KB |
Output is correct |
24 |
Correct |
7 ms |
10452 KB |
Output is correct |
25 |
Correct |
7 ms |
10528 KB |
Output is correct |
26 |
Correct |
7 ms |
10452 KB |
Output is correct |
27 |
Correct |
7 ms |
10428 KB |
Output is correct |
28 |
Correct |
7 ms |
10452 KB |
Output is correct |
29 |
Correct |
64 ms |
10596 KB |
Output is correct |
30 |
Correct |
52 ms |
10632 KB |
Output is correct |
31 |
Correct |
45 ms |
10628 KB |
Output is correct |
32 |
Correct |
35 ms |
10616 KB |
Output is correct |
33 |
Correct |
30 ms |
10580 KB |
Output is correct |
34 |
Correct |
48 ms |
10640 KB |
Output is correct |
35 |
Correct |
57 ms |
10580 KB |
Output is correct |
36 |
Correct |
41 ms |
10616 KB |
Output is correct |
37 |
Correct |
73 ms |
10652 KB |
Output is correct |
38 |
Correct |
78 ms |
10644 KB |
Output is correct |
39 |
Correct |
57 ms |
10652 KB |
Output is correct |
40 |
Correct |
41 ms |
10580 KB |
Output is correct |
41 |
Correct |
44 ms |
10748 KB |
Output is correct |
42 |
Correct |
40 ms |
10636 KB |
Output is correct |
43 |
Correct |
33 ms |
10632 KB |
Output is correct |
44 |
Correct |
33 ms |
10580 KB |
Output is correct |
45 |
Correct |
36 ms |
10640 KB |
Output is correct |
46 |
Correct |
41 ms |
10656 KB |
Output is correct |
47 |
Correct |
43 ms |
10636 KB |
Output is correct |
48 |
Correct |
47 ms |
10628 KB |
Output is correct |
49 |
Correct |
51 ms |
10636 KB |
Output is correct |
50 |
Correct |
54 ms |
10628 KB |
Output is correct |
51 |
Correct |
37 ms |
10580 KB |
Output is correct |
52 |
Correct |
39 ms |
10580 KB |
Output is correct |
53 |
Correct |
44 ms |
10628 KB |
Output is correct |
54 |
Correct |
53 ms |
10632 KB |
Output is correct |
55 |
Correct |
120 ms |
21284 KB |
Output is correct |
56 |
Correct |
262 ms |
22792 KB |
Output is correct |
57 |
Correct |
101 ms |
16484 KB |
Output is correct |
58 |
Correct |
127 ms |
19104 KB |
Output is correct |
59 |
Correct |
122 ms |
18296 KB |
Output is correct |
60 |
Correct |
123 ms |
20152 KB |
Output is correct |
61 |
Correct |
202 ms |
20544 KB |
Output is correct |
62 |
Correct |
167 ms |
20800 KB |
Output is correct |
63 |
Correct |
142 ms |
18228 KB |
Output is correct |
64 |
Correct |
164 ms |
19080 KB |
Output is correct |
65 |
Correct |
117 ms |
17592 KB |
Output is correct |
66 |
Correct |
133 ms |
19032 KB |
Output is correct |
67 |
Correct |
155 ms |
19304 KB |
Output is correct |
68 |
Correct |
217 ms |
19308 KB |
Output is correct |
69 |
Execution timed out |
2072 ms |
22480 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |