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 "library.h"
using namespace std;
void Solve(int N) {
vector<int> a(N, 1);
vector<int> ans;
set<int> st;
for (int i = 1; i <= N; i++) {
st.insert(i);
}
for (int i = 1; i <= N; i++) {
a[i - 1] = 0;
if (Query(a) == 1) {
ans.push_back(i);
st.erase(i);
break;
}
a[i - 1] = 1;
}
for (int t = 0; t < N - 1; t++) {
vector<int> b;
for (auto& x : st) {
b.push_back(x);
}
int l = 0, r = (int) b.size() - 1;
while (l < r) {
int mid = (l + r) / 2;
a.assign(N, 0);
for (int i = l; i <= mid; i++) {
a[b[i] - 1] = 1;
}
int tmp1 = Query(a);
a[ans.back() - 1] = 1;
int tmp2 = Query(a);
if (tmp1 < tmp2) {
l = mid + 1;
} else {
r = mid;
}
}
ans.push_back(b[l]);
st.erase(b[l]);
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |