#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 100010;
// map<ll, int> v;
mt19937 mt_rand(time(NULL));
int cval;
void go(vector<int>& a, vector<int>& b, bool aactive) {
// cout << "as: ";
// for (int vv : a) cout << vv << " ";
// cout << endl;
// cout << "bs: ";
// for (int vv : b) cout << vv << " ";
// cout << endl;
if (a.size() == 2) {
cval = Query(a[0]);
int cur = Query(b[0]);
if (aactive) {
if (cval == cur) {
Answer(a[0], b[1]);
Answer(a[1], b[0]);
}
else {
Answer(a[0], b[0]);
Answer(a[1], b[1]);
}
}
else {
if (cval == cur) {
Answer(a[0], b[0]);
Answer(a[1], b[1]);
}
else {
Answer(a[0], b[1]);
Answer(a[1], b[0]);
}
}
cval = cur;
return;
}
vector<int> al, bl, ar, br;
shuffle(a.begin(), a.end(), mt_rand);
shuffle(b.begin(), b.end(), mt_rand);
if (a.size() == 1 && b.size() == 1) {
Answer(a[0], b[0]);
return;
}
if (a.size() == 0) return;
int mid = a.size()/2;
//modify what is true for all less than this
for (int i = 0; i < mid; i++) {
cval = Query(a[i]);
al.push_back(a[i]);
}
for (int i = mid; i < a.size(); i++) {
ar.push_back(a[i]);
}
for (int i = 0; i < b.size(); i++) {
// cout << "here: " << b[i] << endl;
if (bl.size() == al.size()) {
br.push_back(b[i]);
continue;
}
if (br.size() == ar.size()) {
bl.push_back(b[i]);
continue;
}
int cur = Query(b[i]);
if (cur != cval) {
if (aactive) {
bl.push_back(b[i]);
}
else {
br.push_back(b[i]);
}
}
else {
if (aactive) {
br.push_back(b[i]);
}
else {
bl.push_back(b[i]);
}
}
cval = cur;
}
go(al, bl, !aactive);
go(ar, br, aactive);
}
void Solve(int N) {
// int nrounds = 1000000/N;
vector<int> cl, cr;
cval = 0;
for (int i = 1; i <= 2*N; i++) {
int cur = Query(i);
if (cur == cval) {
cl.push_back(i);
}
else cr.push_back(i);
cval = cur;
}
go(cl, cr, true);
}
Compilation message
minerals.cpp: In function 'void go(std::vector<int>&, std::vector<int>&, bool)':
minerals.cpp:65:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = mid; i < a.size(); i++) {
~~^~~~~~~~~~
minerals.cpp:69:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < b.size(); i++) {
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
12 ms |
640 KB |
Output is correct |
5 |
Correct |
24 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
19 |
Correct |
70 ms |
2596 KB |
Output is correct |
20 |
Correct |
69 ms |
2708 KB |
Output is correct |
21 |
Correct |
67 ms |
2688 KB |
Output is correct |
22 |
Correct |
68 ms |
2504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
19 |
Correct |
70 ms |
2596 KB |
Output is correct |
20 |
Correct |
69 ms |
2708 KB |
Output is correct |
21 |
Correct |
67 ms |
2688 KB |
Output is correct |
22 |
Correct |
68 ms |
2504 KB |
Output is correct |
23 |
Correct |
72 ms |
2768 KB |
Output is correct |
24 |
Correct |
73 ms |
2704 KB |
Output is correct |
25 |
Correct |
71 ms |
2684 KB |
Output is correct |
26 |
Correct |
69 ms |
2516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
19 |
Correct |
70 ms |
2596 KB |
Output is correct |
20 |
Correct |
69 ms |
2708 KB |
Output is correct |
21 |
Correct |
67 ms |
2688 KB |
Output is correct |
22 |
Correct |
68 ms |
2504 KB |
Output is correct |
23 |
Correct |
72 ms |
2768 KB |
Output is correct |
24 |
Correct |
73 ms |
2704 KB |
Output is correct |
25 |
Correct |
71 ms |
2684 KB |
Output is correct |
26 |
Correct |
69 ms |
2516 KB |
Output is correct |
27 |
Correct |
75 ms |
2932 KB |
Output is correct |
28 |
Correct |
80 ms |
2756 KB |
Output is correct |
29 |
Correct |
74 ms |
2844 KB |
Output is correct |
30 |
Correct |
70 ms |
2608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
19 |
Correct |
70 ms |
2596 KB |
Output is correct |
20 |
Correct |
69 ms |
2708 KB |
Output is correct |
21 |
Correct |
67 ms |
2688 KB |
Output is correct |
22 |
Correct |
68 ms |
2504 KB |
Output is correct |
23 |
Correct |
72 ms |
2768 KB |
Output is correct |
24 |
Correct |
73 ms |
2704 KB |
Output is correct |
25 |
Correct |
71 ms |
2684 KB |
Output is correct |
26 |
Correct |
69 ms |
2516 KB |
Output is correct |
27 |
Correct |
75 ms |
2932 KB |
Output is correct |
28 |
Correct |
80 ms |
2756 KB |
Output is correct |
29 |
Correct |
74 ms |
2844 KB |
Output is correct |
30 |
Correct |
70 ms |
2608 KB |
Output is correct |
31 |
Correct |
86 ms |
2804 KB |
Output is correct |
32 |
Correct |
77 ms |
2768 KB |
Output is correct |
33 |
Correct |
75 ms |
2868 KB |
Output is correct |
34 |
Correct |
73 ms |
2640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
12 ms |
640 KB |
Output is correct |
9 |
Correct |
24 ms |
1152 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
1024 KB |
Output is correct |
12 |
Correct |
25 ms |
1152 KB |
Output is correct |
13 |
Correct |
24 ms |
1280 KB |
Output is correct |
14 |
Correct |
24 ms |
1152 KB |
Output is correct |
15 |
Correct |
69 ms |
2556 KB |
Output is correct |
16 |
Correct |
68 ms |
2684 KB |
Output is correct |
17 |
Correct |
67 ms |
2712 KB |
Output is correct |
18 |
Correct |
66 ms |
2552 KB |
Output is correct |
19 |
Correct |
70 ms |
2596 KB |
Output is correct |
20 |
Correct |
69 ms |
2708 KB |
Output is correct |
21 |
Correct |
67 ms |
2688 KB |
Output is correct |
22 |
Correct |
68 ms |
2504 KB |
Output is correct |
23 |
Correct |
72 ms |
2768 KB |
Output is correct |
24 |
Correct |
73 ms |
2704 KB |
Output is correct |
25 |
Correct |
71 ms |
2684 KB |
Output is correct |
26 |
Correct |
69 ms |
2516 KB |
Output is correct |
27 |
Correct |
75 ms |
2932 KB |
Output is correct |
28 |
Correct |
80 ms |
2756 KB |
Output is correct |
29 |
Correct |
74 ms |
2844 KB |
Output is correct |
30 |
Correct |
70 ms |
2608 KB |
Output is correct |
31 |
Correct |
86 ms |
2804 KB |
Output is correct |
32 |
Correct |
77 ms |
2768 KB |
Output is correct |
33 |
Correct |
75 ms |
2868 KB |
Output is correct |
34 |
Correct |
73 ms |
2640 KB |
Output is correct |
35 |
Incorrect |
76 ms |
2844 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |