#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
bool chk[100009];
int query(int x) {
chk[x] = !chk[x];
//printf("query x: %d\n", x);
return Query(x);
}
void answer(int a, int b) {
//printf("answer: (%d, %d)\n", a, b);
Answer(a, b);
}
pair<vi, vi> split(int N) {
vector<int> A, B;
int pr = 0, i = 0;
for(i=1; i<=2*N; i++) {
int Q = query(i);
if(pr != Q) A.push_back(i);
else B.push_back(i);
pr = Q;
}
return {A, B};
}
void go(vector<int> &A, vector<int> &B, bool AC) {
//puts("AB");
//for(auto& it: A) printf("%d ",it); puts("");
//for(auto& it: B) printf("%d ",it); puts("");
int N = A.size();
if(N == 1) {
answer(A[0], B[0]);
return;
}
vector<int> LA, RA, LB, RB;
int m = N/2, pr;
if(!AC) {
//if(N >= 10) m = (int)(1.0*N/1.618);
for(int i=0; i<m; i++) {
pr = query(A[i]);
LA.push_back(A[i]);
}
for(int i=m; i<N; i++) RA.push_back(A[i]);
}
if(AC) {
//if(N >= 10) m = N - (int)(1.0*N/1.618);
for(int i=N-1; i>=m; i--) {
pr = query(A[i]);
RA.push_back(A[i]);
}
for(int i=0; i<m; i++) LA.push_back(A[i]);
}
int i;
for(i=0; i<N; i++) {
int Q = query(B[i]);
if(pr != Q) RB.push_back(B[i]);
else LB.push_back(B[i]);
if(RB.size() == RA.size()) break;
if(LB.size() == LA.size()) break;
pr = Q;
}
if(RB.size() == RA.size()) for(++i; i<N; i++) LB.push_back(B[i]);
else for(++i; i<N; i++) RB.push_back(B[i]);
go(LA, LB, 1);
go(RA, RB, 0);
}
void Solve(int N) {
vi A, B; tie(A, B) = split(N);
go(A, B, 1);
}
Compilation message
minerals.cpp: In function 'void go(std::vector<int>&, std::vector<int>&, bool)':
minerals.cpp:61:9: warning: 'pr' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(pr != Q) RB.push_back(B[i]);
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
9 ms |
640 KB |
Output is correct |
5 |
Correct |
16 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
19 |
Correct |
43 ms |
2748 KB |
Output is correct |
20 |
Correct |
43 ms |
2756 KB |
Output is correct |
21 |
Correct |
32 ms |
2620 KB |
Output is correct |
22 |
Correct |
34 ms |
2616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
19 |
Correct |
43 ms |
2748 KB |
Output is correct |
20 |
Correct |
43 ms |
2756 KB |
Output is correct |
21 |
Correct |
32 ms |
2620 KB |
Output is correct |
22 |
Correct |
34 ms |
2616 KB |
Output is correct |
23 |
Correct |
44 ms |
2788 KB |
Output is correct |
24 |
Correct |
47 ms |
2796 KB |
Output is correct |
25 |
Correct |
34 ms |
2740 KB |
Output is correct |
26 |
Correct |
34 ms |
2612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
19 |
Correct |
43 ms |
2748 KB |
Output is correct |
20 |
Correct |
43 ms |
2756 KB |
Output is correct |
21 |
Correct |
32 ms |
2620 KB |
Output is correct |
22 |
Correct |
34 ms |
2616 KB |
Output is correct |
23 |
Correct |
44 ms |
2788 KB |
Output is correct |
24 |
Correct |
47 ms |
2796 KB |
Output is correct |
25 |
Correct |
34 ms |
2740 KB |
Output is correct |
26 |
Correct |
34 ms |
2612 KB |
Output is correct |
27 |
Correct |
46 ms |
2840 KB |
Output is correct |
28 |
Correct |
47 ms |
2836 KB |
Output is correct |
29 |
Correct |
35 ms |
2780 KB |
Output is correct |
30 |
Correct |
34 ms |
2604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
19 |
Correct |
43 ms |
2748 KB |
Output is correct |
20 |
Correct |
43 ms |
2756 KB |
Output is correct |
21 |
Correct |
32 ms |
2620 KB |
Output is correct |
22 |
Correct |
34 ms |
2616 KB |
Output is correct |
23 |
Correct |
44 ms |
2788 KB |
Output is correct |
24 |
Correct |
47 ms |
2796 KB |
Output is correct |
25 |
Correct |
34 ms |
2740 KB |
Output is correct |
26 |
Correct |
34 ms |
2612 KB |
Output is correct |
27 |
Correct |
46 ms |
2840 KB |
Output is correct |
28 |
Correct |
47 ms |
2836 KB |
Output is correct |
29 |
Correct |
35 ms |
2780 KB |
Output is correct |
30 |
Correct |
34 ms |
2604 KB |
Output is correct |
31 |
Correct |
48 ms |
3084 KB |
Output is correct |
32 |
Correct |
47 ms |
2852 KB |
Output is correct |
33 |
Correct |
35 ms |
2772 KB |
Output is correct |
34 |
Correct |
34 ms |
2852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
9 ms |
640 KB |
Output is correct |
9 |
Correct |
16 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
16 ms |
1280 KB |
Output is correct |
13 |
Correct |
13 ms |
1172 KB |
Output is correct |
14 |
Correct |
12 ms |
1096 KB |
Output is correct |
15 |
Correct |
42 ms |
2764 KB |
Output is correct |
16 |
Correct |
44 ms |
2764 KB |
Output is correct |
17 |
Correct |
31 ms |
2628 KB |
Output is correct |
18 |
Correct |
31 ms |
2448 KB |
Output is correct |
19 |
Correct |
43 ms |
2748 KB |
Output is correct |
20 |
Correct |
43 ms |
2756 KB |
Output is correct |
21 |
Correct |
32 ms |
2620 KB |
Output is correct |
22 |
Correct |
34 ms |
2616 KB |
Output is correct |
23 |
Correct |
44 ms |
2788 KB |
Output is correct |
24 |
Correct |
47 ms |
2796 KB |
Output is correct |
25 |
Correct |
34 ms |
2740 KB |
Output is correct |
26 |
Correct |
34 ms |
2612 KB |
Output is correct |
27 |
Correct |
46 ms |
2840 KB |
Output is correct |
28 |
Correct |
47 ms |
2836 KB |
Output is correct |
29 |
Correct |
35 ms |
2780 KB |
Output is correct |
30 |
Correct |
34 ms |
2604 KB |
Output is correct |
31 |
Correct |
48 ms |
3084 KB |
Output is correct |
32 |
Correct |
47 ms |
2852 KB |
Output is correct |
33 |
Correct |
35 ms |
2772 KB |
Output is correct |
34 |
Correct |
34 ms |
2852 KB |
Output is correct |
35 |
Incorrect |
46 ms |
2960 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |