#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int in[100010];
void solve(vector<int> v1,vector<int> v2,bool in1){
random_shuffle(v1.begin(),v1.end());
random_shuffle(v2.begin(),v2.end());
if (v1.size() == 1){
Answer(v1[0],v2[0]);
return;
}
int stop = max((int)(v1.size()*0.382),1);
vector<int> v1a,v1b,v2a,v2b;
int num;
for (int i = 0; i < v1.size(); i++){
if (i < stop){
num = Query(v1[i]);
//if (in[v1[i]]) cout << "Added" << " " << v1[i] << "\n";
//else cout << "Removed" << " " << v1[i] << "\n";
v1a.push_back(v1[i]);
}
else{
v1b.push_back(v1[i]);
}
}
for (int i = 0; i < v2.size(); i++){
if (v2a.size() == stop){
v2b.push_back(v2[i]);
continue;
}
if (v2b.size() == v2.size()-stop){
v2a.push_back(v2[i]);
continue;
}
int temp = Query(v2[i]);
if (in1 && in[v2[i]]){
if (temp < num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
else if (in1 && !in[v2[i]]){
if (temp > num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
else if (!in1 && in[v2[i]]){
if (temp == num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
else{
if (temp == num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
in[v2[i]] = 1-in[v2[i]];
num = temp;
}
solve(v1a,v2a,!in1);
solve(v1b,v2b,in1);
}
void Solve(int N) {
srand(3082);
n = N;
vector<int> v1,v2;
int num = 0;
for (int i = 1; i <= 2*N; i++){
if (v1.size() == N){
v2.push_back(i);
continue;
}
int temp = Query(i);
in[i] = 1;
if (temp > num){
num++;
v1.push_back(i);
}
else{
v2.push_back(i);
}
}
solve(v1,v2,1);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v1.size(); i++){
~~^~~~~~~~~~~
minerals.cpp:27:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v2.size(); i++){
~~^~~~~~~~~~~
minerals.cpp:28:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (v2a.size() == stop){
~~~~~~~~~~~^~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:65:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (v1.size() == N){
~~~~~~~~~~^~~~
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:38:13: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (temp < num) v2a.push_back(v2[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 |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
8 ms |
640 KB |
Output is correct |
4 |
Correct |
16 ms |
1024 KB |
Output is correct |
5 |
Correct |
32 ms |
1680 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 KB |
Output is correct |
19 |
Correct |
93 ms |
3896 KB |
Output is correct |
20 |
Correct |
92 ms |
4032 KB |
Output is correct |
21 |
Correct |
87 ms |
3900 KB |
Output is correct |
22 |
Correct |
89 ms |
3776 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 KB |
Output is correct |
19 |
Correct |
93 ms |
3896 KB |
Output is correct |
20 |
Correct |
92 ms |
4032 KB |
Output is correct |
21 |
Correct |
87 ms |
3900 KB |
Output is correct |
22 |
Correct |
89 ms |
3776 KB |
Output is correct |
23 |
Correct |
94 ms |
3972 KB |
Output is correct |
24 |
Correct |
97 ms |
3968 KB |
Output is correct |
25 |
Correct |
93 ms |
3968 KB |
Output is correct |
26 |
Correct |
92 ms |
3844 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 KB |
Output is correct |
19 |
Correct |
93 ms |
3896 KB |
Output is correct |
20 |
Correct |
92 ms |
4032 KB |
Output is correct |
21 |
Correct |
87 ms |
3900 KB |
Output is correct |
22 |
Correct |
89 ms |
3776 KB |
Output is correct |
23 |
Correct |
94 ms |
3972 KB |
Output is correct |
24 |
Correct |
97 ms |
3968 KB |
Output is correct |
25 |
Correct |
93 ms |
3968 KB |
Output is correct |
26 |
Correct |
92 ms |
3844 KB |
Output is correct |
27 |
Correct |
93 ms |
4136 KB |
Output is correct |
28 |
Correct |
99 ms |
4136 KB |
Output is correct |
29 |
Correct |
95 ms |
4136 KB |
Output is correct |
30 |
Correct |
94 ms |
4004 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 KB |
Output is correct |
19 |
Correct |
93 ms |
3896 KB |
Output is correct |
20 |
Correct |
92 ms |
4032 KB |
Output is correct |
21 |
Correct |
87 ms |
3900 KB |
Output is correct |
22 |
Correct |
89 ms |
3776 KB |
Output is correct |
23 |
Correct |
94 ms |
3972 KB |
Output is correct |
24 |
Correct |
97 ms |
3968 KB |
Output is correct |
25 |
Correct |
93 ms |
3968 KB |
Output is correct |
26 |
Correct |
92 ms |
3844 KB |
Output is correct |
27 |
Correct |
93 ms |
4136 KB |
Output is correct |
28 |
Correct |
99 ms |
4136 KB |
Output is correct |
29 |
Correct |
95 ms |
4136 KB |
Output is correct |
30 |
Correct |
94 ms |
4004 KB |
Output is correct |
31 |
Correct |
100 ms |
4372 KB |
Output is correct |
32 |
Correct |
97 ms |
4188 KB |
Output is correct |
33 |
Correct |
94 ms |
4196 KB |
Output is correct |
34 |
Correct |
96 ms |
4092 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 |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
8 ms |
640 KB |
Output is correct |
8 |
Correct |
16 ms |
1024 KB |
Output is correct |
9 |
Correct |
32 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
1500 KB |
Output is correct |
12 |
Correct |
34 ms |
1780 KB |
Output is correct |
13 |
Correct |
31 ms |
1700 KB |
Output is correct |
14 |
Correct |
32 ms |
1680 KB |
Output is correct |
15 |
Correct |
88 ms |
3832 KB |
Output is correct |
16 |
Correct |
94 ms |
3832 KB |
Output is correct |
17 |
Correct |
87 ms |
3828 KB |
Output is correct |
18 |
Correct |
84 ms |
3704 KB |
Output is correct |
19 |
Correct |
93 ms |
3896 KB |
Output is correct |
20 |
Correct |
92 ms |
4032 KB |
Output is correct |
21 |
Correct |
87 ms |
3900 KB |
Output is correct |
22 |
Correct |
89 ms |
3776 KB |
Output is correct |
23 |
Correct |
94 ms |
3972 KB |
Output is correct |
24 |
Correct |
97 ms |
3968 KB |
Output is correct |
25 |
Correct |
93 ms |
3968 KB |
Output is correct |
26 |
Correct |
92 ms |
3844 KB |
Output is correct |
27 |
Correct |
93 ms |
4136 KB |
Output is correct |
28 |
Correct |
99 ms |
4136 KB |
Output is correct |
29 |
Correct |
95 ms |
4136 KB |
Output is correct |
30 |
Correct |
94 ms |
4004 KB |
Output is correct |
31 |
Correct |
100 ms |
4372 KB |
Output is correct |
32 |
Correct |
97 ms |
4188 KB |
Output is correct |
33 |
Correct |
94 ms |
4196 KB |
Output is correct |
34 |
Correct |
96 ms |
4092 KB |
Output is correct |
35 |
Correct |
105 ms |
4288 KB |
Output is correct |
36 |
Correct |
101 ms |
4288 KB |
Output is correct |
37 |
Correct |
102 ms |
4284 KB |
Output is correct |
38 |
Correct |
97 ms |
4160 KB |
Output is correct |