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 <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
void Solve(int n) {
if(n == 1) {
Answer({1});
return;
}
else if(n == 2) {
Answer({1,2});
return;
}
vector<int> bruh(n,1);
vector<int> ans(n);
vector<int> yeah(n+1,1);
int p = -1;
for(int i = 0; i < n; i++) {
bruh[i] = 0;
if(Query(bruh) == 1) {
ans[0] = i+1;
p = i+1;
yeah[i+1] = 0;
break;
}
bruh[i] = 1;
}
for(int i = 1; i < n; i++) {
vector<int> wut(0);
for(int j = 1; j <= n; j++) {
if(yeah[j]) {
wut.push_back(j);
}
}
int l = 0,r = wut.size()-1;
while(l < r) {
for(int j = 0; j < n; j++) {
bruh[j] = 0;
}
int mid = (l+r)/2;
for(int j = 0; j <= mid; j++) {
bruh[wut[j]-1] = 1;
}
int c = Query(bruh);
bruh[p-1] = 1;
if(Query(bruh) == c) {
r = mid;
}
else {
l = mid+1;
}
}
p = wut[l];
yeah[p] = 0;
ans[i] = p;
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |