This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int last = 0;
bool ask(int x) {
int nw = Query(x);
bool g = (last != nw);
last = nw;
return g;
}
void solve(vector<int> a, vector<int> b, bool f) {
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size();
int mid = (int) max(1.0, n * 0.4);
vector<int> la, lb, ra, rb;
for (int i = 0; i < n; i++) {
if (i < mid) ask(b[i]), lb.push_back(b[i]);
else rb.push_back(b[i]);
}
for (int i : a) {
if (la.size() == mid) ra.push_back(i);
else if (ra.size() == n - mid) la.push_back(i);
else if (f) {
if (ask(i)) ra.push_back(i);
else la.push_back(i);
} else {
if (ask(i)) la.push_back(i);
else ra.push_back(i);
}
}
solve(la, lb, f ^ 1);
solve(ra, rb, f);
}
void Solve(int N) {
vector<int> a, b;
for (int i = 1; i <= 2 * N; i++) {
if (ask(i)) a.push_back(i);
else b.push_back(i);
}
solve(a, b, 0);
}
Compilation message (stderr)
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | if (la.size() == mid) ra.push_back(i);
| ~~~~~~~~~~^~~~~~
minerals.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | else if (ra.size() == n - mid) la.push_back(i);
| ~~~~~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |