이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n){
vector<int> res;
vector<int> q(n, 1);
vector<int> t(n);
iota(t.begin(), t.end(), 1);
for(int i = 1; i <= n; i ++){
q[i - 1] = 0;
if(Query(q) == 1){
res.push_back(i);
t.erase(t.begin() + i - 1);
q[i - 1] = 1;
break;
}
q[i - 1] = 1;
}
q = vector<int>(n, 0);
while((int)res.size() < n){
int l = 0, r = (int)t.size() - 1;
while(l < r){
int m = (l + r) / 2;
for(int i = l; i <= m; i ++) q[t[i] - 1] = 1;
int res1 = Query(q);
q[res.back() - 1] = 1;
int res2 = Query(q);
q[res.back() - 1] = 0;
for(int i = l; i <= m; i ++) q[t[i] - 1] = 0;
if(res1 == res2) r = m;
else l = m + 1;
}
res.push_back(t[l]);
t.erase(t.begin() + l);
}
Answer(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |