#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000005;
void dnc(vector<int> l, vector<int> r, int toggle){
if(l.size() == 1){
Answer(l[0], r[0]);
return;
}
int m = 0.35 * l.size(), last = 0;
vector<int> ll, lr, rr, rl;
m = max(m, 1); m = min(m, (int)l.size() - 1);
for(int i=0; i<m; i++){
last = Query(l[i]);
ll.push_back(l[i]);
}
for(int i=m; i<l.size(); i++){
lr.push_back(l[i]);
}
for(int i=0; i<r.size(); i++){
if(rl.size() == ll.size()){
rr.push_back(r[i]);
continue;
}
if(rr.size() == lr.size()){
rl.push_back(r[i]);
continue;
}
int nxt = Query(r[i]);
if(toggle ^ (nxt != last)){
rr.push_back(r[i]);
}
else rl.push_back(r[i]);
last = nxt;
}
dnc(ll, rl, toggle ^ 1);
dnc(lr, rr, toggle);
}
void Solve(int N) {
srand(time(0));
vector<int> l, r;
vector<int> perm(2 * N);
iota(perm.begin(), perm.end(), 1);
random_shuffle(perm.begin(), perm.end());
for(auto &i : perm){
int v = Query(i);
if(v != l.size()){
l.push_back(i);
}
else{
r.push_back(i);
}
}
dnc(l, r, 1);
}
Compilation message
minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, int)':
minerals.cpp:18:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=m; i<l.size(); i++){
~^~~~~~~~~
minerals.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<r.size(); i++){
~^~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:50:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(v != l.size()){
~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
768 KB |
Output is correct |
4 |
Correct |
12 ms |
1080 KB |
Output is correct |
5 |
Correct |
22 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
19 |
Correct |
59 ms |
4132 KB |
Output is correct |
20 |
Correct |
62 ms |
4160 KB |
Output is correct |
21 |
Correct |
57 ms |
4132 KB |
Output is correct |
22 |
Correct |
58 ms |
4008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
19 |
Correct |
59 ms |
4132 KB |
Output is correct |
20 |
Correct |
62 ms |
4160 KB |
Output is correct |
21 |
Correct |
57 ms |
4132 KB |
Output is correct |
22 |
Correct |
58 ms |
4008 KB |
Output is correct |
23 |
Correct |
61 ms |
4252 KB |
Output is correct |
24 |
Correct |
63 ms |
4204 KB |
Output is correct |
25 |
Correct |
73 ms |
4192 KB |
Output is correct |
26 |
Correct |
59 ms |
4068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
19 |
Correct |
59 ms |
4132 KB |
Output is correct |
20 |
Correct |
62 ms |
4160 KB |
Output is correct |
21 |
Correct |
57 ms |
4132 KB |
Output is correct |
22 |
Correct |
58 ms |
4008 KB |
Output is correct |
23 |
Correct |
61 ms |
4252 KB |
Output is correct |
24 |
Correct |
63 ms |
4204 KB |
Output is correct |
25 |
Correct |
73 ms |
4192 KB |
Output is correct |
26 |
Correct |
59 ms |
4068 KB |
Output is correct |
27 |
Correct |
62 ms |
4328 KB |
Output is correct |
28 |
Correct |
64 ms |
4272 KB |
Output is correct |
29 |
Correct |
61 ms |
4360 KB |
Output is correct |
30 |
Correct |
62 ms |
4284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
19 |
Correct |
59 ms |
4132 KB |
Output is correct |
20 |
Correct |
62 ms |
4160 KB |
Output is correct |
21 |
Correct |
57 ms |
4132 KB |
Output is correct |
22 |
Correct |
58 ms |
4008 KB |
Output is correct |
23 |
Correct |
61 ms |
4252 KB |
Output is correct |
24 |
Correct |
63 ms |
4204 KB |
Output is correct |
25 |
Correct |
73 ms |
4192 KB |
Output is correct |
26 |
Correct |
59 ms |
4068 KB |
Output is correct |
27 |
Correct |
62 ms |
4328 KB |
Output is correct |
28 |
Correct |
64 ms |
4272 KB |
Output is correct |
29 |
Correct |
61 ms |
4360 KB |
Output is correct |
30 |
Correct |
62 ms |
4284 KB |
Output is correct |
31 |
Correct |
66 ms |
4420 KB |
Output is correct |
32 |
Correct |
67 ms |
4320 KB |
Output is correct |
33 |
Correct |
61 ms |
4384 KB |
Output is correct |
34 |
Correct |
63 ms |
4256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
412 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 |
7 ms |
768 KB |
Output is correct |
8 |
Correct |
12 ms |
1080 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
15 ms |
1372 KB |
Output is correct |
12 |
Correct |
22 ms |
1724 KB |
Output is correct |
13 |
Correct |
21 ms |
1804 KB |
Output is correct |
14 |
Correct |
20 ms |
1684 KB |
Output is correct |
15 |
Correct |
58 ms |
4040 KB |
Output is correct |
16 |
Correct |
57 ms |
4020 KB |
Output is correct |
17 |
Correct |
57 ms |
4036 KB |
Output is correct |
18 |
Correct |
56 ms |
3852 KB |
Output is correct |
19 |
Correct |
59 ms |
4132 KB |
Output is correct |
20 |
Correct |
62 ms |
4160 KB |
Output is correct |
21 |
Correct |
57 ms |
4132 KB |
Output is correct |
22 |
Correct |
58 ms |
4008 KB |
Output is correct |
23 |
Correct |
61 ms |
4252 KB |
Output is correct |
24 |
Correct |
63 ms |
4204 KB |
Output is correct |
25 |
Correct |
73 ms |
4192 KB |
Output is correct |
26 |
Correct |
59 ms |
4068 KB |
Output is correct |
27 |
Correct |
62 ms |
4328 KB |
Output is correct |
28 |
Correct |
64 ms |
4272 KB |
Output is correct |
29 |
Correct |
61 ms |
4360 KB |
Output is correct |
30 |
Correct |
62 ms |
4284 KB |
Output is correct |
31 |
Correct |
66 ms |
4420 KB |
Output is correct |
32 |
Correct |
67 ms |
4320 KB |
Output is correct |
33 |
Correct |
61 ms |
4384 KB |
Output is correct |
34 |
Correct |
63 ms |
4256 KB |
Output is correct |
35 |
Correct |
64 ms |
4532 KB |
Output is correct |
36 |
Correct |
67 ms |
4432 KB |
Output is correct |
37 |
Correct |
63 ms |
4660 KB |
Output is correct |
38 |
Correct |
63 ms |
4276 KB |
Output is correct |