#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
vector<int> Q;
vector<int> P;
int ans[86005];
int ON[86005];
int last;
int query(int x){
ON[x] ^= 1;
return Query(x);
}
void solve(vector<int> p, int l, int r, int flag){
if (r == l){
ans[Q[l]] = p[0];
return;
}
#ifdef debug
printf("new <%d,%d> %d\n",l,r,flag);
for (auto x : p){
printf("%d ",x);
}
printf("<- P\n");
for (int i = l; i <= r; i++){
printf("%d ",Q[i]);
}
printf("<- Q\n");
#endif
//assert(p.size() == r-l+1);
vector<int> Lp;
vector<int> Rp;
int n = r-l+1;
int mid;
mid = (l+r)/2;
if (flag){
for (int i = mid+1; i <= r; i++){
last = query(Q[i]);
}
}
else{
for (int i = l; i <= mid; i++){
last = query(Q[i]);
}
}
for (int i = 0; i < n; i++){
int q = query(p[i]);
if (q == last){
Lp.push_back(p[i]);
}
else{
Rp.push_back(p[i]);
}
if (Lp.size() == mid-l+1 || Rp.size() == r-mid){
//printf("ALL FILLED\n");
for (int j = i+1; j < n; j++){
if (Lp.size() == mid-l+1) Rp.push_back(p[j]);
else Lp.push_back(p[j]);
}
break;
}
last = q;
}
#ifdef debug
printf("Lp: ");
for (auto x : Lp) printf("%d ",x);
printf("\n");
printf("Rp: ");
for (auto x : Rp) printf("%d ",x);
printf("\n");
#endif
solve(Lp, l, mid, 1);
solve(Rp, mid+1, r, 0);
}
void Solve(int N) {
int last = 0;
for (int i = 1; i <= 2*N; i++){
int q = query(i);
if (q == last){
Q.push_back(i);
}
else{
P.push_back(i);
}
last = q;
ON[i] = 1;
}
srand(time(NULL));
random_shuffle(Q.begin(),Q.end());
random_shuffle(P.begin(),P.end());
solve(P,0,N-1,1);
for (auto x: Q){
Answer(x,ans[x]);
}
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, int, int, int)':
minerals.cpp:57:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Lp.size() == mid-l+1 || Rp.size() == r-mid){
~~~~~~~~~~^~~~~~~~~~
minerals.cpp:57:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Lp.size() == mid-l+1 || Rp.size() == r-mid){
~~~~~~~~~~^~~~~~~~
minerals.cpp:60:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Lp.size() == mid-l+1) Rp.push_back(p[j]);
~~~~~~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
10 ms |
896 KB |
Output is correct |
5 |
Correct |
25 ms |
1216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
19 |
Correct |
58 ms |
2932 KB |
Output is correct |
20 |
Correct |
58 ms |
2940 KB |
Output is correct |
21 |
Correct |
60 ms |
2888 KB |
Output is correct |
22 |
Correct |
60 ms |
2596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
19 |
Correct |
58 ms |
2932 KB |
Output is correct |
20 |
Correct |
58 ms |
2940 KB |
Output is correct |
21 |
Correct |
60 ms |
2888 KB |
Output is correct |
22 |
Correct |
60 ms |
2596 KB |
Output is correct |
23 |
Correct |
61 ms |
2940 KB |
Output is correct |
24 |
Correct |
63 ms |
2932 KB |
Output is correct |
25 |
Correct |
62 ms |
3032 KB |
Output is correct |
26 |
Correct |
55 ms |
2572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
19 |
Correct |
58 ms |
2932 KB |
Output is correct |
20 |
Correct |
58 ms |
2940 KB |
Output is correct |
21 |
Correct |
60 ms |
2888 KB |
Output is correct |
22 |
Correct |
60 ms |
2596 KB |
Output is correct |
23 |
Correct |
61 ms |
2940 KB |
Output is correct |
24 |
Correct |
63 ms |
2932 KB |
Output is correct |
25 |
Correct |
62 ms |
3032 KB |
Output is correct |
26 |
Correct |
55 ms |
2572 KB |
Output is correct |
27 |
Correct |
59 ms |
3044 KB |
Output is correct |
28 |
Correct |
61 ms |
3060 KB |
Output is correct |
29 |
Correct |
61 ms |
3196 KB |
Output is correct |
30 |
Correct |
57 ms |
2756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
19 |
Correct |
58 ms |
2932 KB |
Output is correct |
20 |
Correct |
58 ms |
2940 KB |
Output is correct |
21 |
Correct |
60 ms |
2888 KB |
Output is correct |
22 |
Correct |
60 ms |
2596 KB |
Output is correct |
23 |
Correct |
61 ms |
2940 KB |
Output is correct |
24 |
Correct |
63 ms |
2932 KB |
Output is correct |
25 |
Correct |
62 ms |
3032 KB |
Output is correct |
26 |
Correct |
55 ms |
2572 KB |
Output is correct |
27 |
Correct |
59 ms |
3044 KB |
Output is correct |
28 |
Correct |
61 ms |
3060 KB |
Output is correct |
29 |
Correct |
61 ms |
3196 KB |
Output is correct |
30 |
Correct |
57 ms |
2756 KB |
Output is correct |
31 |
Correct |
67 ms |
3136 KB |
Output is correct |
32 |
Correct |
62 ms |
3084 KB |
Output is correct |
33 |
Correct |
59 ms |
3084 KB |
Output is correct |
34 |
Correct |
59 ms |
2716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
25 ms |
1216 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
1136 KB |
Output is correct |
12 |
Correct |
19 ms |
1344 KB |
Output is correct |
13 |
Correct |
18 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
1224 KB |
Output is correct |
15 |
Correct |
55 ms |
2912 KB |
Output is correct |
16 |
Correct |
55 ms |
2804 KB |
Output is correct |
17 |
Correct |
55 ms |
2836 KB |
Output is correct |
18 |
Correct |
54 ms |
2556 KB |
Output is correct |
19 |
Correct |
58 ms |
2932 KB |
Output is correct |
20 |
Correct |
58 ms |
2940 KB |
Output is correct |
21 |
Correct |
60 ms |
2888 KB |
Output is correct |
22 |
Correct |
60 ms |
2596 KB |
Output is correct |
23 |
Correct |
61 ms |
2940 KB |
Output is correct |
24 |
Correct |
63 ms |
2932 KB |
Output is correct |
25 |
Correct |
62 ms |
3032 KB |
Output is correct |
26 |
Correct |
55 ms |
2572 KB |
Output is correct |
27 |
Correct |
59 ms |
3044 KB |
Output is correct |
28 |
Correct |
61 ms |
3060 KB |
Output is correct |
29 |
Correct |
61 ms |
3196 KB |
Output is correct |
30 |
Correct |
57 ms |
2756 KB |
Output is correct |
31 |
Correct |
67 ms |
3136 KB |
Output is correct |
32 |
Correct |
62 ms |
3084 KB |
Output is correct |
33 |
Correct |
59 ms |
3084 KB |
Output is correct |
34 |
Correct |
59 ms |
2716 KB |
Output is correct |
35 |
Incorrect |
62 ms |
3068 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |