#include "minerals.h"
#include<vector>
#include<set>
using namespace std;
int n, s;
void solve0(vector<int>& in, vector<int>& rest);
void solve(vector<int>& in, vector<int>& rest) {
if (in.size() == 1) { Query(in[0]); Answer(in[0], rest[0]); return; }
//better cut - not 1/2
vector<int> in1, in2;
for (int i = 0; i < in.size() / 2; i++) in1.push_back(in[i]);
for (int i = in.size() / 2; i < in.size(); i++) in2.push_back(in[i]);
//get rest for in1. possible better - not to take out right away
for (int i : in2) Query(i);
vector<int> rest1, rest2;
for (int j : rest) {
int u = Query(j);
if (u == in1.size()) rest1.push_back(j);
else {
rest2.push_back(j);
Query(j);
}
}
solve0(in1, rest1);
for (int i : in2) Query(i);
solve(in2, rest2);
}
void solve0(vector<int>& in, vector<int>& rest) {// rest are also in
if (in.size() == 1) { Query(in[0]); Query(rest[0]); Answer(in[0], rest[0]); return; }
//better cut - not 1/2
vector<int> in1, in2;
for (int i = 0; i < in.size() / 2; i++) in1.push_back(in[i]);
for (int i = in.size() / 2; i < in.size(); i++) in2.push_back(in[i]);
//get rest for in1. possible better - not to take out right away
int sz = 0;
for (int i : in2) sz = Query(i);
vector<int> rest1, rest2;
for (int j : rest) {
int u = Query(j); //Query(j);
if (u == sz) rest1.push_back(j);
else {
sz = u; rest2.push_back(j);
}
}
solve(in1, rest1);
for (int i : in2) Query(i);
solve(in2, rest2);
}
void Solve(int N) {
n = N; s = n << 1;
int sz = 0;
vector<int> in, rest;
for (int i = 1; i <= s; i++) {
int u = Query(i);
if (u > sz) {
sz = u;
in.push_back(i);
}
else {
rest.push_back(i);
}
}
solve0(in, rest);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>&, std::vector<int>&)':
minerals.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i = 0; i < in.size() / 2; i++) in1.push_back(in[i]);
| ~~^~~~~~~~~~~~~~~
minerals.cpp:14:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = in.size() / 2; i < in.size(); i++) in2.push_back(in[i]);
| ~~^~~~~~~~~~~
minerals.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | if (u == in1.size()) rest1.push_back(j);
| ~~^~~~~~~~~~~~~
minerals.cpp: In function 'void solve0(std::vector<int>&, std::vector<int>&)':
minerals.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i = 0; i < in.size() / 2; i++) in1.push_back(in[i]);
| ~~^~~~~~~~~~~~~~~
minerals.cpp:38:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = in.size() / 2; i < in.size(); i++) in2.push_back(in[i]);
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
356 KB |
Output is correct |
2 |
Correct |
1 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
612 KB |
Output is correct |
4 |
Correct |
6 ms |
744 KB |
Output is correct |
5 |
Correct |
9 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
356 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
6 ms |
744 KB |
Output is correct |
9 |
Correct |
9 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
856 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
8 ms |
1368 KB |
Output is correct |
14 |
Correct |
7 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
18 ms |
2648 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |