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 <bits/stdc++.h>
#include "minerals.h"
using namespace std;
int last = 0;
bool ask(int x) {
int now = Query(x);
bool ar_naujas = (now != last);
last = now;
return ar_naujas;
}
#define p(x) cout << (#x) << ":\n";print(x)
void print(vector<int>& a) {
for(int i : a) {
cout << i << " ";
}
cout << "\n";
}
void go(vector<int> pirmas, vector<int> antras, bool flag=false) {
int n = pirmas.size(), m = (int) ceil((double) n * 0.4);
//p(pirmas);
//p(antras);
assert(n != 0);
if (n == 1) {
Answer(pirmas[0], antras[0]);
return;
}
if (flag) {
m = n - m;
for(int i = m; i < n; i++) {
ask(pirmas[i]);
}
}
else {
for(int i = 0; i < m; i++) {
ask(pirmas[i]);
}
}
vector<int> naujas_pirmas, naujas_antras;
random_shuffle(antras.begin(), antras.end());
for(const auto& i : antras) {
if ((int) naujas_pirmas.size() == n) {
naujas_antras.push_back(i);
}
else if ((int) naujas_antras.size() == n-m) {
naujas_pirmas.push_back(i);
}
else if (ask(i)) {
naujas_antras.push_back(i);
}
else {
naujas_pirmas.push_back(i);
}
}
vector<int> half, other_half;
for(int i = 0; i < n; i++) {
if (i < m) {
half.push_back(pirmas[i]);
}
else {
other_half.push_back(pirmas[i]);
}
}
//p(half);
//p(naujas_pirmas);
//p(other_half);
//p(naujas_antras);
go(half, naujas_pirmas, true);
go(other_half, naujas_antras);
}
void Solve(int N) {
vector<int> pirmas, antras;
for(int i = 1; i <= 2*N; i++) {
if (ask(i)) {
pirmas.push_back(i);
}
else {
antras.push_back(i);
}
}
go(pirmas, antras, true);
}
# | 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... |