#include "minerals.h"
// #include "grader.cpp"
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
const int mxN = 2e5 + 5;
int inside[mxN], tot;
int get(int x){
if(inside[x])
tot--;
else
tot++;
inside[x] ^= 1;
return tot - Query(x);
}
void goKill(set<int> a, set<int> b, bool aInside, bool bInside){
// cout << a.size() << ' ' << b.size() << ' ' << aInside << ' ' << bInside << '\n';
if(a.size() == 1){
Answer(*a.begin(), *b.begin());
// cout << *a.begin() << ' ' << *b.begin() << '\n';
return;
}
int sz = a.size();
set<int> x, y;
int b4;
for(int j = 1; j <= sz / 2; j++){
int v = *a.begin();
a.erase(v);
x.insert(v);
b4 = get(v);
}
for(auto it : b){
int v = get(it);
if((!aInside && v != b4)||(aInside && v == b4)){
y.insert(it);
}
b4 = v;
}
for(auto v : y)b.erase(v);
goKill(x,y,aInside^1,bInside^1);
goKill(a,b,aInside,bInside^1);
}
void Solve(int N) {
int n = N + N;
set<int> a, b;
int b4 = 0;
for (int i = 1; i <= n; i++) {
int x = get(i);
if(x > b4){
a.insert(i);
} else {
b.insert(i);
}
b4 = x;
}
// cout << a.size() << ' ' << b.size() << '\n';
goKill(a, b, 1, 1);
}
Compilation message
minerals.cpp: In function 'void goKill(std::set<int>, std::set<int>, bool, bool)':
minerals.cpp:34:29: warning: 'b4' may be used uninitialized in this function [-Wmaybe-uninitialized]
if((!aInside && v != b4)||(aInside && v == b4)){
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
10 ms |
888 KB |
Output is correct |
3 |
Correct |
20 ms |
1656 KB |
Output is correct |
4 |
Correct |
42 ms |
2808 KB |
Output is correct |
5 |
Correct |
86 ms |
5112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
19 |
Correct |
272 ms |
12792 KB |
Output is correct |
20 |
Correct |
279 ms |
12732 KB |
Output is correct |
21 |
Correct |
201 ms |
12892 KB |
Output is correct |
22 |
Correct |
201 ms |
12660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
19 |
Correct |
272 ms |
12792 KB |
Output is correct |
20 |
Correct |
279 ms |
12732 KB |
Output is correct |
21 |
Correct |
201 ms |
12892 KB |
Output is correct |
22 |
Correct |
201 ms |
12660 KB |
Output is correct |
23 |
Correct |
276 ms |
13124 KB |
Output is correct |
24 |
Correct |
272 ms |
13172 KB |
Output is correct |
25 |
Correct |
208 ms |
13080 KB |
Output is correct |
26 |
Correct |
207 ms |
13048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
19 |
Correct |
272 ms |
12792 KB |
Output is correct |
20 |
Correct |
279 ms |
12732 KB |
Output is correct |
21 |
Correct |
201 ms |
12892 KB |
Output is correct |
22 |
Correct |
201 ms |
12660 KB |
Output is correct |
23 |
Correct |
276 ms |
13124 KB |
Output is correct |
24 |
Correct |
272 ms |
13172 KB |
Output is correct |
25 |
Correct |
208 ms |
13080 KB |
Output is correct |
26 |
Correct |
207 ms |
13048 KB |
Output is correct |
27 |
Incorrect |
260 ms |
13448 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
19 |
Correct |
272 ms |
12792 KB |
Output is correct |
20 |
Correct |
279 ms |
12732 KB |
Output is correct |
21 |
Correct |
201 ms |
12892 KB |
Output is correct |
22 |
Correct |
201 ms |
12660 KB |
Output is correct |
23 |
Correct |
276 ms |
13124 KB |
Output is correct |
24 |
Correct |
272 ms |
13172 KB |
Output is correct |
25 |
Correct |
208 ms |
13080 KB |
Output is correct |
26 |
Correct |
207 ms |
13048 KB |
Output is correct |
27 |
Incorrect |
260 ms |
13448 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
20 ms |
1656 KB |
Output is correct |
8 |
Correct |
42 ms |
2808 KB |
Output is correct |
9 |
Correct |
86 ms |
5112 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
54 ms |
3448 KB |
Output is correct |
12 |
Correct |
89 ms |
5308 KB |
Output is correct |
13 |
Correct |
68 ms |
5112 KB |
Output is correct |
14 |
Correct |
69 ms |
4984 KB |
Output is correct |
15 |
Correct |
261 ms |
12560 KB |
Output is correct |
16 |
Correct |
285 ms |
12536 KB |
Output is correct |
17 |
Correct |
191 ms |
12536 KB |
Output is correct |
18 |
Correct |
197 ms |
12408 KB |
Output is correct |
19 |
Correct |
272 ms |
12792 KB |
Output is correct |
20 |
Correct |
279 ms |
12732 KB |
Output is correct |
21 |
Correct |
201 ms |
12892 KB |
Output is correct |
22 |
Correct |
201 ms |
12660 KB |
Output is correct |
23 |
Correct |
276 ms |
13124 KB |
Output is correct |
24 |
Correct |
272 ms |
13172 KB |
Output is correct |
25 |
Correct |
208 ms |
13080 KB |
Output is correct |
26 |
Correct |
207 ms |
13048 KB |
Output is correct |
27 |
Incorrect |
260 ms |
13448 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |