#include "minerals.h"
#include <algorithm>
#include <vector>
using namespace std;
vector<int> firsts, ans;
int lquery = 0;
void recurse(vector<int> &v, int l, int r, bool has = true) {
if (l != r) {
int m = l + (r - l) * 0.38;
for (int i = l; i <= m; ++i) lquery = Query(firsts[i]);
vector<int> a, b;
for (int i: v) {
if (a.size() != m - l + 1 && b.size() != r - m) {
int x = Query(i);
if (has == (x != lquery)) a.push_back(i);
else b.push_back(i);
if (x != lquery) lquery = x;
} else if (a.size() != m - l + 1) a.push_back(i);
else b.push_back(i);
}
recurse(a, l, m, !has);
recurse(b, m + 1, r, has);
} else ans.push_back(v[0]);
}
void Solve(int N) {
vector<int> duds;
for (int i = 1; i <= 2 * N; ++i) {
int x = Query(i);
if (x != lquery) firsts.push_back(i), lquery = x;
else duds.push_back(i);
}
random_shuffle(firsts.begin(), firsts.end());
recurse(duds, 0, N - 1);
for (int i = 0; i < N; ++i) Answer(firsts[i], ans[i]);
}
Compilation message
minerals.cpp: In function 'void recurse(std::vector<int>&, int, int, bool)':
minerals.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (a.size() != m - l + 1 && b.size() != r - m) {
~~~~~~~~~^~~~~~~~~~~~
minerals.cpp:13:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (a.size() != m - l + 1 && b.size() != r - m) {
~~~~~~~~~^~~~~~~~
minerals.cpp:18:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
} else if (a.size() != m - l + 1) a.push_back(i);
~~~~~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
768 KB |
Output is correct |
5 |
Correct |
14 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
19 |
Correct |
47 ms |
2292 KB |
Output is correct |
20 |
Correct |
42 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2292 KB |
Output is correct |
22 |
Correct |
44 ms |
2164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
19 |
Correct |
47 ms |
2292 KB |
Output is correct |
20 |
Correct |
42 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2292 KB |
Output is correct |
22 |
Correct |
44 ms |
2164 KB |
Output is correct |
23 |
Correct |
41 ms |
2420 KB |
Output is correct |
24 |
Correct |
43 ms |
2292 KB |
Output is correct |
25 |
Correct |
43 ms |
2420 KB |
Output is correct |
26 |
Correct |
40 ms |
2292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
19 |
Correct |
47 ms |
2292 KB |
Output is correct |
20 |
Correct |
42 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2292 KB |
Output is correct |
22 |
Correct |
44 ms |
2164 KB |
Output is correct |
23 |
Correct |
41 ms |
2420 KB |
Output is correct |
24 |
Correct |
43 ms |
2292 KB |
Output is correct |
25 |
Correct |
43 ms |
2420 KB |
Output is correct |
26 |
Correct |
40 ms |
2292 KB |
Output is correct |
27 |
Correct |
49 ms |
2544 KB |
Output is correct |
28 |
Correct |
43 ms |
2420 KB |
Output is correct |
29 |
Correct |
43 ms |
2460 KB |
Output is correct |
30 |
Correct |
40 ms |
2292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
19 |
Correct |
47 ms |
2292 KB |
Output is correct |
20 |
Correct |
42 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2292 KB |
Output is correct |
22 |
Correct |
44 ms |
2164 KB |
Output is correct |
23 |
Correct |
41 ms |
2420 KB |
Output is correct |
24 |
Correct |
43 ms |
2292 KB |
Output is correct |
25 |
Correct |
43 ms |
2420 KB |
Output is correct |
26 |
Correct |
40 ms |
2292 KB |
Output is correct |
27 |
Correct |
49 ms |
2544 KB |
Output is correct |
28 |
Correct |
43 ms |
2420 KB |
Output is correct |
29 |
Correct |
43 ms |
2460 KB |
Output is correct |
30 |
Correct |
40 ms |
2292 KB |
Output is correct |
31 |
Correct |
44 ms |
2420 KB |
Output is correct |
32 |
Correct |
45 ms |
2408 KB |
Output is correct |
33 |
Correct |
41 ms |
2420 KB |
Output is correct |
34 |
Correct |
41 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
14 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
896 KB |
Output is correct |
12 |
Correct |
14 ms |
1152 KB |
Output is correct |
13 |
Correct |
14 ms |
1152 KB |
Output is correct |
14 |
Correct |
14 ms |
1280 KB |
Output is correct |
15 |
Correct |
43 ms |
2292 KB |
Output is correct |
16 |
Correct |
41 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2292 KB |
Output is correct |
18 |
Correct |
44 ms |
2164 KB |
Output is correct |
19 |
Correct |
47 ms |
2292 KB |
Output is correct |
20 |
Correct |
42 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2292 KB |
Output is correct |
22 |
Correct |
44 ms |
2164 KB |
Output is correct |
23 |
Correct |
41 ms |
2420 KB |
Output is correct |
24 |
Correct |
43 ms |
2292 KB |
Output is correct |
25 |
Correct |
43 ms |
2420 KB |
Output is correct |
26 |
Correct |
40 ms |
2292 KB |
Output is correct |
27 |
Correct |
49 ms |
2544 KB |
Output is correct |
28 |
Correct |
43 ms |
2420 KB |
Output is correct |
29 |
Correct |
43 ms |
2460 KB |
Output is correct |
30 |
Correct |
40 ms |
2292 KB |
Output is correct |
31 |
Correct |
44 ms |
2420 KB |
Output is correct |
32 |
Correct |
45 ms |
2408 KB |
Output is correct |
33 |
Correct |
41 ms |
2420 KB |
Output is correct |
34 |
Correct |
41 ms |
2260 KB |
Output is correct |
35 |
Correct |
46 ms |
2420 KB |
Output is correct |
36 |
Correct |
46 ms |
2420 KB |
Output is correct |
37 |
Correct |
42 ms |
2464 KB |
Output is correct |
38 |
Correct |
42 ms |
2292 KB |
Output is correct |