이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |