#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int n;
void solve(vector<int> v1,vector<int> v2,bool in1,bool in2){
if (v1.size() == 1){
Answer(v1[0],v2[0]);
return;
}
int stop = v1.size()/2;
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 (in[v2[i]]) cout << "Added" << " " << v2[i] << "\n";
//else cout << "Removed" << " " << v2[i] << "\n";
int temp = Query(v2[i]);
if (in1 && in2){
if (temp < num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
else if (in1 && !in2){
if (temp > num) v2a.push_back(v2[i]);
else v2b.push_back(v2[i]);
}
else if (!in1 && in2){
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]);
}
num = temp;
}
solve(v1a,v2a,!in1,!in2);
solve(v1b,v2b,in1,!in2);
}
void Solve(int N) {
n = N;
vector<int> v1,v2;
int num = 0;
for (int i = 1; i <= 2*N; i++){
int temp = Query(i);
if (temp > num){
num++;
v1.push_back(i);
}
else{
v2.push_back(i);
}
}
solve(v1,v2,1,1);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool, bool)':
minerals.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v1.size(); i++){
~~^~~~~~~~~~~
minerals.cpp:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v2.size(); i++){
~~^~~~~~~~~~~
minerals.cpp:29:13: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (temp < num) v2a.push_back(v2[i]);
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
10 ms |
896 KB |
Output is correct |
5 |
Correct |
20 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
19 |
Correct |
61 ms |
3280 KB |
Output is correct |
20 |
Correct |
68 ms |
3280 KB |
Output is correct |
21 |
Correct |
52 ms |
3144 KB |
Output is correct |
22 |
Correct |
50 ms |
3064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
19 |
Correct |
61 ms |
3280 KB |
Output is correct |
20 |
Correct |
68 ms |
3280 KB |
Output is correct |
21 |
Correct |
52 ms |
3144 KB |
Output is correct |
22 |
Correct |
50 ms |
3064 KB |
Output is correct |
23 |
Correct |
58 ms |
3380 KB |
Output is correct |
24 |
Correct |
65 ms |
3380 KB |
Output is correct |
25 |
Correct |
52 ms |
3216 KB |
Output is correct |
26 |
Correct |
56 ms |
3152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
19 |
Correct |
61 ms |
3280 KB |
Output is correct |
20 |
Correct |
68 ms |
3280 KB |
Output is correct |
21 |
Correct |
52 ms |
3144 KB |
Output is correct |
22 |
Correct |
50 ms |
3064 KB |
Output is correct |
23 |
Correct |
58 ms |
3380 KB |
Output is correct |
24 |
Correct |
65 ms |
3380 KB |
Output is correct |
25 |
Correct |
52 ms |
3216 KB |
Output is correct |
26 |
Correct |
56 ms |
3152 KB |
Output is correct |
27 |
Incorrect |
59 ms |
3476 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
19 |
Correct |
61 ms |
3280 KB |
Output is correct |
20 |
Correct |
68 ms |
3280 KB |
Output is correct |
21 |
Correct |
52 ms |
3144 KB |
Output is correct |
22 |
Correct |
50 ms |
3064 KB |
Output is correct |
23 |
Correct |
58 ms |
3380 KB |
Output is correct |
24 |
Correct |
65 ms |
3380 KB |
Output is correct |
25 |
Correct |
52 ms |
3216 KB |
Output is correct |
26 |
Correct |
56 ms |
3152 KB |
Output is correct |
27 |
Incorrect |
59 ms |
3476 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
10 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
20 ms |
1452 KB |
Output is correct |
13 |
Correct |
17 ms |
1460 KB |
Output is correct |
14 |
Correct |
27 ms |
1324 KB |
Output is correct |
15 |
Correct |
58 ms |
3224 KB |
Output is correct |
16 |
Correct |
58 ms |
3352 KB |
Output is correct |
17 |
Correct |
53 ms |
3164 KB |
Output is correct |
18 |
Correct |
51 ms |
2992 KB |
Output is correct |
19 |
Correct |
61 ms |
3280 KB |
Output is correct |
20 |
Correct |
68 ms |
3280 KB |
Output is correct |
21 |
Correct |
52 ms |
3144 KB |
Output is correct |
22 |
Correct |
50 ms |
3064 KB |
Output is correct |
23 |
Correct |
58 ms |
3380 KB |
Output is correct |
24 |
Correct |
65 ms |
3380 KB |
Output is correct |
25 |
Correct |
52 ms |
3216 KB |
Output is correct |
26 |
Correct |
56 ms |
3152 KB |
Output is correct |
27 |
Incorrect |
59 ms |
3476 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |