이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "library.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define m_p make_pair
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
void Solve(int n){
if(n==1){
Answer({1});
return;
}
vec<int> ans;
for(int i=0;i<n;i++){
vec<int> h(n,1);
h[i]=0;
if(Query(h)==1)
ans.pb(i);
}
int last=ans.back();
ans.pop_back();
for(int i=1;i<n-1;i++){
vec<int> here;
vec<int>u(n);
for(auto &j : ans)
u[j]=1;
for(int j=0;j<n;j++){
if(!u[j])
here.pb(j);
}
while(sz(here)!=1){
vec<int> lft,rgt;
vec<int> ask(n,0);
for(int j=0;j<sz(here)/2;j++) ask[here[j]]=1,lft.pb(here[j]);
for(int j=sz(lft);j<sz(here);j++) rgt.pb(here[j]);
int fi=Query(ask);
ask[ans.back()]=1;
int si=Query(ask);
if(fi==si) here=lft;
else here=rgt;
}
ans.pb(here[0]);
}
ans.pb(last);
for(auto &z : ans) ++z;
// for(auto &z : ans)
// cout<<z<<' ';
// cout<<endl;
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |