# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
541542 | fadi57 | 도서관 (JOI18_library) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
//#include "library.h"
#include "grader.cpp"
#include "bits/stdc++.h"
using namespace std;
void Solve(int n)
{
if(n==1){
vector<int>ans;
ans={1};
Answer (ans);
return;
}
vector<int>q(n,1);int st=0;
for(int i=0;i<n;i++){
q[i]=0;
int x=Query(q);
q[i]=1;
if(x==1){
st=i;}
}
vector<int>ans;
ans.push_back(st);
vector<int>comp;
for(int i=0;i<n;i++){
if(i!=st){
comp.push_back(i);
}
}
while(comp.size()){
int s=0; int en=comp.size()-1;
while(s<=en){
int mid=(s+en)/2;
vector<int>Q(n,0);
for(int j=0;j<=mid;j++){
Q[comp[j]]=1;
}
int x=Query(Q);
Q[ans.back()]=1;
int y=Query(Q);
if(y==x){
en=mid-1;
}else{
s=mid+1;
}
}
ans.push_back(comp[s]);
swap(comp[s], comp.back());
comp.pop_back();
}
for(auto &it:ans){it++;
}
Answer(ans);
}