#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
vector<int> Q;
vector<int> P;
int ans[86005];
void solve(vector<int> p, int l, int r, int flag){
if (r == l){
//printf("%d -> %d\n",Q[l],p[0]);
Answer(Q[l],p[0]);
return;
}
#ifdef debug
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 m = l +(r-l)*0.38;
int last;
for (int i = l; i <= m; i++){
last = Query(Q[i]);
}
for (auto x : p){
if (Rp.size() == r-m) Lp.push_back(x);
else if (Lp.size() == m-l+1) Rp.push_back(x);
else{
int q = Query(x);
if ((q == last) != flag){
Lp.push_back(x);
}
else{
Rp.push_back(x);
}
last = q;
}
}
solve(Lp, l, m, !flag);
solve(Rp, m+1, r, flag);
}
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;
}
solve(P,0,N-1,1);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, int, int, int)':
minerals.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Rp.size() == r-m) Lp.push_back(x);
~~~~~~~~~~^~~~~~
minerals.cpp:36:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if (Lp.size() == m-l+1) Rp.push_back(x);
~~~~~~~~~~^~~~~~~~
minerals.cpp:26:9: warning: unused variable 'n' [-Wunused-variable]
int n = r-l+1;
^
# |
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 |
1 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 |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
8 ms |
768 KB |
Output is correct |
5 |
Correct |
14 ms |
1280 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
40 ms |
2804 KB |
Output is correct |
20 |
Correct |
41 ms |
2780 KB |
Output is correct |
21 |
Correct |
30 ms |
2804 KB |
Output is correct |
22 |
Correct |
32 ms |
2604 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
40 ms |
2804 KB |
Output is correct |
20 |
Correct |
41 ms |
2780 KB |
Output is correct |
21 |
Correct |
30 ms |
2804 KB |
Output is correct |
22 |
Correct |
32 ms |
2604 KB |
Output is correct |
23 |
Correct |
42 ms |
2804 KB |
Output is correct |
24 |
Correct |
42 ms |
2804 KB |
Output is correct |
25 |
Correct |
31 ms |
2892 KB |
Output is correct |
26 |
Correct |
33 ms |
2728 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
40 ms |
2804 KB |
Output is correct |
20 |
Correct |
41 ms |
2780 KB |
Output is correct |
21 |
Correct |
30 ms |
2804 KB |
Output is correct |
22 |
Correct |
32 ms |
2604 KB |
Output is correct |
23 |
Correct |
42 ms |
2804 KB |
Output is correct |
24 |
Correct |
42 ms |
2804 KB |
Output is correct |
25 |
Correct |
31 ms |
2892 KB |
Output is correct |
26 |
Correct |
33 ms |
2728 KB |
Output is correct |
27 |
Correct |
43 ms |
2932 KB |
Output is correct |
28 |
Correct |
45 ms |
2884 KB |
Output is correct |
29 |
Correct |
34 ms |
2888 KB |
Output is correct |
30 |
Correct |
35 ms |
2728 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
40 ms |
2804 KB |
Output is correct |
20 |
Correct |
41 ms |
2780 KB |
Output is correct |
21 |
Correct |
30 ms |
2804 KB |
Output is correct |
22 |
Correct |
32 ms |
2604 KB |
Output is correct |
23 |
Correct |
42 ms |
2804 KB |
Output is correct |
24 |
Correct |
42 ms |
2804 KB |
Output is correct |
25 |
Correct |
31 ms |
2892 KB |
Output is correct |
26 |
Correct |
33 ms |
2728 KB |
Output is correct |
27 |
Correct |
43 ms |
2932 KB |
Output is correct |
28 |
Correct |
45 ms |
2884 KB |
Output is correct |
29 |
Correct |
34 ms |
2888 KB |
Output is correct |
30 |
Correct |
35 ms |
2728 KB |
Output is correct |
31 |
Correct |
50 ms |
2932 KB |
Output is correct |
32 |
Correct |
53 ms |
2932 KB |
Output is correct |
33 |
Correct |
40 ms |
3012 KB |
Output is correct |
34 |
Correct |
36 ms |
2724 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 |
1 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 |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1024 KB |
Output is correct |
12 |
Correct |
15 ms |
1280 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
41 ms |
2840 KB |
Output is correct |
16 |
Correct |
43 ms |
2676 KB |
Output is correct |
17 |
Correct |
30 ms |
2688 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
40 ms |
2804 KB |
Output is correct |
20 |
Correct |
41 ms |
2780 KB |
Output is correct |
21 |
Correct |
30 ms |
2804 KB |
Output is correct |
22 |
Correct |
32 ms |
2604 KB |
Output is correct |
23 |
Correct |
42 ms |
2804 KB |
Output is correct |
24 |
Correct |
42 ms |
2804 KB |
Output is correct |
25 |
Correct |
31 ms |
2892 KB |
Output is correct |
26 |
Correct |
33 ms |
2728 KB |
Output is correct |
27 |
Correct |
43 ms |
2932 KB |
Output is correct |
28 |
Correct |
45 ms |
2884 KB |
Output is correct |
29 |
Correct |
34 ms |
2888 KB |
Output is correct |
30 |
Correct |
35 ms |
2728 KB |
Output is correct |
31 |
Correct |
50 ms |
2932 KB |
Output is correct |
32 |
Correct |
53 ms |
2932 KB |
Output is correct |
33 |
Correct |
40 ms |
3012 KB |
Output is correct |
34 |
Correct |
36 ms |
2724 KB |
Output is correct |
35 |
Correct |
45 ms |
2936 KB |
Output is correct |
36 |
Correct |
47 ms |
3048 KB |
Output is correct |
37 |
Correct |
34 ms |
3016 KB |
Output is correct |
38 |
Correct |
36 ms |
2848 KB |
Output is correct |