#include "minerals.h"
#include <bits/stdc++.h>
#define All(x) x.begin(), x.end()
#define pb emplace_back
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
int pre, now;
void check(vector <int> A, vector <int> B, bool flagA, bool flagB) {
assert(A.size());
if (A.size() == 1) {
Answer(A[0], B[0]);
return;
}
int len = max<int>(1, B.size() / exp(1));
vector <int> LA, RA, LB, RB;
for (int i = 0; i < len; i++) {
pre = now;
now = Query(B[i]);
LB.pb(B[i]);
}
for (int i = len; i < B.size(); i++) {
RB.pb(B[i]);
}
for (int i = 0; i < A.size(); i++) {
pre = now;
now = Query(A[i]);
if (LA.size() == len) {
RA.pb(A[i]);
continue;
} else if (RA.size() == A.size() - len) {
LA.pb(A[i]);
continue;
}
if ( (!flagA && !flagB && now == pre)
|| (!flagA && flagB && now == pre+1)
|| ( flagA && !flagB && now == pre)
|| ( flagA && flagB && now == pre-1)) {
LA.pb(A[i]);
} else {
RA.pb(A[i]);
}
}
check(LA, LB, !flagA, !flagB);
check(RA, RB, !flagA, flagB);
}
void Solve(int N) {
// srand(time(NULL));
vector <int> num(2*N);
for (int i = 0; i < 2*N; i++) num[i] = i+1;
// random_shuffle(All(num));
vector <int> A, B;
for (int id : num) {
pre = now;
now = Query(id);
if (now != pre + 1) {
B.pb(id);
} else {
A.pb(id);
}
}
check(A, B, true, true);
}
Compilation message
minerals.cpp: In function 'void check(std::vector<int>, std::vector<int>, bool, bool)':
minerals.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i = len; i < B.size(); i++) {
| ~~^~~~~~~~~~
minerals.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i = 0; i < A.size(); i++) {
| ~~^~~~~~~~~~
minerals.cpp:32:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
32 | if (LA.size() == len) {
| ~~~~~~~~~~^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
748 KB |
Output is correct |
4 |
Correct |
10 ms |
1132 KB |
Output is correct |
5 |
Correct |
19 ms |
1772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
19 |
Correct |
56 ms |
3948 KB |
Output is correct |
20 |
Correct |
53 ms |
4076 KB |
Output is correct |
21 |
Correct |
50 ms |
4072 KB |
Output is correct |
22 |
Correct |
50 ms |
3948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
19 |
Correct |
56 ms |
3948 KB |
Output is correct |
20 |
Correct |
53 ms |
4076 KB |
Output is correct |
21 |
Correct |
50 ms |
4072 KB |
Output is correct |
22 |
Correct |
50 ms |
3948 KB |
Output is correct |
23 |
Correct |
54 ms |
4076 KB |
Output is correct |
24 |
Correct |
55 ms |
4076 KB |
Output is correct |
25 |
Correct |
46 ms |
4200 KB |
Output is correct |
26 |
Correct |
45 ms |
3948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
19 |
Correct |
56 ms |
3948 KB |
Output is correct |
20 |
Correct |
53 ms |
4076 KB |
Output is correct |
21 |
Correct |
50 ms |
4072 KB |
Output is correct |
22 |
Correct |
50 ms |
3948 KB |
Output is correct |
23 |
Correct |
54 ms |
4076 KB |
Output is correct |
24 |
Correct |
55 ms |
4076 KB |
Output is correct |
25 |
Correct |
46 ms |
4200 KB |
Output is correct |
26 |
Correct |
45 ms |
3948 KB |
Output is correct |
27 |
Correct |
61 ms |
4248 KB |
Output is correct |
28 |
Correct |
58 ms |
4204 KB |
Output is correct |
29 |
Correct |
49 ms |
4200 KB |
Output is correct |
30 |
Correct |
48 ms |
4076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
19 |
Correct |
56 ms |
3948 KB |
Output is correct |
20 |
Correct |
53 ms |
4076 KB |
Output is correct |
21 |
Correct |
50 ms |
4072 KB |
Output is correct |
22 |
Correct |
50 ms |
3948 KB |
Output is correct |
23 |
Correct |
54 ms |
4076 KB |
Output is correct |
24 |
Correct |
55 ms |
4076 KB |
Output is correct |
25 |
Correct |
46 ms |
4200 KB |
Output is correct |
26 |
Correct |
45 ms |
3948 KB |
Output is correct |
27 |
Correct |
61 ms |
4248 KB |
Output is correct |
28 |
Correct |
58 ms |
4204 KB |
Output is correct |
29 |
Correct |
49 ms |
4200 KB |
Output is correct |
30 |
Correct |
48 ms |
4076 KB |
Output is correct |
31 |
Incorrect |
57 ms |
4332 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
10 ms |
1132 KB |
Output is correct |
9 |
Correct |
19 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
17 ms |
1260 KB |
Output is correct |
12 |
Correct |
22 ms |
1776 KB |
Output is correct |
13 |
Correct |
19 ms |
1772 KB |
Output is correct |
14 |
Correct |
17 ms |
1792 KB |
Output is correct |
15 |
Correct |
52 ms |
3948 KB |
Output is correct |
16 |
Correct |
53 ms |
4076 KB |
Output is correct |
17 |
Correct |
49 ms |
3944 KB |
Output is correct |
18 |
Correct |
44 ms |
3820 KB |
Output is correct |
19 |
Correct |
56 ms |
3948 KB |
Output is correct |
20 |
Correct |
53 ms |
4076 KB |
Output is correct |
21 |
Correct |
50 ms |
4072 KB |
Output is correct |
22 |
Correct |
50 ms |
3948 KB |
Output is correct |
23 |
Correct |
54 ms |
4076 KB |
Output is correct |
24 |
Correct |
55 ms |
4076 KB |
Output is correct |
25 |
Correct |
46 ms |
4200 KB |
Output is correct |
26 |
Correct |
45 ms |
3948 KB |
Output is correct |
27 |
Correct |
61 ms |
4248 KB |
Output is correct |
28 |
Correct |
58 ms |
4204 KB |
Output is correct |
29 |
Correct |
49 ms |
4200 KB |
Output is correct |
30 |
Correct |
48 ms |
4076 KB |
Output is correct |
31 |
Incorrect |
57 ms |
4332 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |