#include <iostream>
#include <vector>
#include <set>
#include "minerals.h"
using namespace std;
set<int> on;
void solve(vector<int> a, vector<int> b) {
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size() / 2, m = a.size() - n;
vector<int> a1(n), a2(m);
vector<int> b1, b2;
for (int i = 0; i < n; ++i) a1[i] = a[i];
for (int i = 0; i < m; ++i) a2[i] = a[i + n];
for (int i : a1) if (!on.count(i)) Query(i), on.insert(i);
for (int i : a2) if (on.count(i)) Query(i), on.erase(i);
for (int i = 0; i < n + m; ++i) {
int now = Query(b[i]);
if (now == on.size()) b1.push_back(b[i]);
else b2.push_back(b[i]);
Query(b[i]);
}
// for (int i = 0; i < n; ++i) Query(a[i]);
solve(a1, b1), solve(a2, b2);
}
void Solve(int n) {
vector<int> a, b;
int last = 0;
for (int i = 1; i <= 2 * n; ++i) {
int now = Query(i);
if (now > last) a.push_back(i), on.insert(i);
else b.push_back(i);
last = now;
}
for (int i : b) Query(i);
solve(a, b);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:23:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | if (now == on.size()) b1.push_back(b[i]);
| ~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
7 ms |
592 KB |
Output is correct |
4 |
Correct |
14 ms |
1104 KB |
Output is correct |
5 |
Correct |
32 ms |
1812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
7 ms |
592 KB |
Output is correct |
8 |
Correct |
14 ms |
1104 KB |
Output is correct |
9 |
Correct |
32 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1384 KB |
Output is correct |
12 |
Correct |
31 ms |
1820 KB |
Output is correct |
13 |
Correct |
30 ms |
1864 KB |
Output is correct |
14 |
Correct |
31 ms |
1736 KB |
Output is correct |
15 |
Incorrect |
65 ms |
4072 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |