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"
#define pb emplace_back
#define ll long long
using namespace std;
const int N = int(2e3) + 7;
vector<int> m, ans, s;
int low, high, mid, cur;
void Solve(int n) {
if(n == 1) {Answer({1}); return;}
m.resize(n, 1); s.resize(n);
for(int i = 0; i < n; ++i) {
m[i] = 0;
if(Query(m) == 1) {cur = i; break;}
m[i] = 1;
}
iota(s.begin(), s.end(), 0);
ans.pb(cur + 1);
s.erase(find(s.begin(), s.end(), cur));
while(s.size()) {
low = 0, high = s.size() - 1;
while(low <= high) {
mid = (low + high) >> 1;
fill(m.begin(), m.end(), 0);
for(int i = 0; i <= mid; ++i) m[s[i]] = 1;
int res = Query(m);
m[cur] = 1;
if(res == Query(m)) high = mid - 1;
else low = mid + 1;
}
cur = s[low];
ans.pb(cur + 1);
s.erase(find(s.begin(), s.end(), cur));
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |