#include <bits/stdc++.h>
using namespace std;
#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.5;
int last;
for (int i = l; i <= m; i++){
last = Query(Q[i]);
}
for (int i = 0; i < n; i++){
if (Rp.size() == r-m) Lp.push_back(p[i]);
else if (Lp.size() == m-l+1) Rp.push_back(p[i]);
else{
int q = Query(p[i]);
if ((q == last) != flag){
Lp.push_back(p[i]);
}
else{
Rp.push_back(p[i]);
}
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:36:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Rp.size() == r-m) Lp.push_back(p[i]);
~~~~~~~~~~^~~~~~
minerals.cpp:37:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if (Lp.size() == m-l+1) Rp.push_back(p[i]);
~~~~~~~~~~^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
8 ms |
704 KB |
Output is correct |
5 |
Correct |
17 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
19 |
Correct |
49 ms |
2596 KB |
Output is correct |
20 |
Correct |
48 ms |
2624 KB |
Output is correct |
21 |
Correct |
42 ms |
2560 KB |
Output is correct |
22 |
Correct |
32 ms |
2440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
19 |
Correct |
49 ms |
2596 KB |
Output is correct |
20 |
Correct |
48 ms |
2624 KB |
Output is correct |
21 |
Correct |
42 ms |
2560 KB |
Output is correct |
22 |
Correct |
32 ms |
2440 KB |
Output is correct |
23 |
Correct |
47 ms |
2688 KB |
Output is correct |
24 |
Correct |
54 ms |
2628 KB |
Output is correct |
25 |
Correct |
37 ms |
2548 KB |
Output is correct |
26 |
Correct |
38 ms |
2480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
19 |
Correct |
49 ms |
2596 KB |
Output is correct |
20 |
Correct |
48 ms |
2624 KB |
Output is correct |
21 |
Correct |
42 ms |
2560 KB |
Output is correct |
22 |
Correct |
32 ms |
2440 KB |
Output is correct |
23 |
Correct |
47 ms |
2688 KB |
Output is correct |
24 |
Correct |
54 ms |
2628 KB |
Output is correct |
25 |
Correct |
37 ms |
2548 KB |
Output is correct |
26 |
Correct |
38 ms |
2480 KB |
Output is correct |
27 |
Correct |
51 ms |
2680 KB |
Output is correct |
28 |
Correct |
47 ms |
2680 KB |
Output is correct |
29 |
Correct |
34 ms |
2680 KB |
Output is correct |
30 |
Correct |
48 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
19 |
Correct |
49 ms |
2596 KB |
Output is correct |
20 |
Correct |
48 ms |
2624 KB |
Output is correct |
21 |
Correct |
42 ms |
2560 KB |
Output is correct |
22 |
Correct |
32 ms |
2440 KB |
Output is correct |
23 |
Correct |
47 ms |
2688 KB |
Output is correct |
24 |
Correct |
54 ms |
2628 KB |
Output is correct |
25 |
Correct |
37 ms |
2548 KB |
Output is correct |
26 |
Correct |
38 ms |
2480 KB |
Output is correct |
27 |
Correct |
51 ms |
2680 KB |
Output is correct |
28 |
Correct |
47 ms |
2680 KB |
Output is correct |
29 |
Correct |
34 ms |
2680 KB |
Output is correct |
30 |
Correct |
48 ms |
2552 KB |
Output is correct |
31 |
Correct |
50 ms |
2788 KB |
Output is correct |
32 |
Correct |
55 ms |
2684 KB |
Output is correct |
33 |
Correct |
37 ms |
2676 KB |
Output is correct |
34 |
Correct |
38 ms |
2548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
8 ms |
704 KB |
Output is correct |
9 |
Correct |
17 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
13 ms |
896 KB |
Output is correct |
12 |
Correct |
17 ms |
1152 KB |
Output is correct |
13 |
Correct |
15 ms |
1152 KB |
Output is correct |
14 |
Correct |
12 ms |
1152 KB |
Output is correct |
15 |
Correct |
43 ms |
2548 KB |
Output is correct |
16 |
Correct |
43 ms |
2588 KB |
Output is correct |
17 |
Correct |
33 ms |
2564 KB |
Output is correct |
18 |
Correct |
36 ms |
2388 KB |
Output is correct |
19 |
Correct |
49 ms |
2596 KB |
Output is correct |
20 |
Correct |
48 ms |
2624 KB |
Output is correct |
21 |
Correct |
42 ms |
2560 KB |
Output is correct |
22 |
Correct |
32 ms |
2440 KB |
Output is correct |
23 |
Correct |
47 ms |
2688 KB |
Output is correct |
24 |
Correct |
54 ms |
2628 KB |
Output is correct |
25 |
Correct |
37 ms |
2548 KB |
Output is correct |
26 |
Correct |
38 ms |
2480 KB |
Output is correct |
27 |
Correct |
51 ms |
2680 KB |
Output is correct |
28 |
Correct |
47 ms |
2680 KB |
Output is correct |
29 |
Correct |
34 ms |
2680 KB |
Output is correct |
30 |
Correct |
48 ms |
2552 KB |
Output is correct |
31 |
Correct |
50 ms |
2788 KB |
Output is correct |
32 |
Correct |
55 ms |
2684 KB |
Output is correct |
33 |
Correct |
37 ms |
2676 KB |
Output is correct |
34 |
Correct |
38 ms |
2548 KB |
Output is correct |
35 |
Incorrect |
51 ms |
2804 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |