이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "library.h"
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll MOD=1000000007LL;
const ll INF=(1<<30);
const ll LINF=(1LL<<60);
template<typename T> void chmax(T &a,T b){a=max(a,b);}
template<typename T> void chmin(T &a,T b){a=min(a,b);}
void Solve(int N){
if(N==1){
Answer(vector<int>(1,1));
return;
}
int pos;
vector<int> vis(N+10);
for(int i=1;i<=N;i++){
vector<int> v(N);
for(int j=1;j<=N;j++){
if(i==j)continue;
v[j-1]=1;
}
int q=Query(v);
if(q==1){
pos=i;
vis[pos]=1;
break;
}
}
vector<int> ans;
ans.push_back(pos);
for(int i=0;i<N-1;i++){
vector<int> v,vv(N);
for(int j=1;j<=N;j++){
if(vis[j])continue;
v.push_back(j);
}
sort(all(v));
int ng=0,ok=v.size();
while(ok-ng>1){
int mid=(ok+ng)/2;
for(int j=0;j<N;j++)vv[j]=0;
for(int j=0;j<mid;j++)vv[v[j]-1]=1;
int q1=Query(vv);
vv[pos-1]=1;
int q2=Query(vv);
if(q1==q2){
ok=mid;
}else{
ng=mid;
}
}
pos=v[ok-1];
vis[pos]=1;
ans.push_back(pos);
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |