#include<bits/stdc++.h>
#include "library.h"
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
bool use[1009];
void Solve(int n){
vector<vector<int>>gr;
//cout<<Query({1,1,1,1,0})<<'\n';
gr.pb({1});
for1(i,2,5){
vector<int>t;
for1(j,1,i)t.pb(j);
vector<int>t1;
for1(j,1,n)use[j]=0;
for (auto v:t){
use[v]=1;
}
for1(j,1,n){
t1.pb(use[j]);
}
int nans=Query(t1);
//cout<<i<<" "<<nans<<'\n';
if (nans==sz(gr)+1){
gr.pb({i});
continue;
}
else if (nans==sz(gr)){
int l=0,r=sz(gr)-1,ans=r;
//cerr<<l<<" "<<r<<'\n';
while (l<=r){
int mid=(l+r)/2;
vector<int>tt;
for1(j,0,mid){
for(auto v:gr[j]){
tt.pb(v);
}
}
//cerr<<mid<<'\n';
tt.pb(i);
for1(j,1,n)use[j]=0;
for (auto v:tt){
use[v]=1;
}
vector<int>tt1;
for1(j,1,n)tt1.pb(use[j]);
int val=Query(tt1);
if (val==mid+1){
ans=mid;
r=mid-1;
}
else l=mid+1;
}
gr[ans].pb(i);
//cerr<<ans<<'\n';
continue;
}
else{
int l=0,r=sz(gr)-1,ans=r;
while (l<=r){
int mid=(l+r)/2;
vector<int>tt;
for1(j,0,mid){
for(auto v:gr[j]){
tt.pb(v);
}
}
tt.pb(i);
vector<int>tt1;
for1(j,1,n)use[j]=0;
for (auto v:tt){
use[v]=1;
}
for1(j,1,n)tt1.pb(use[j]);
int val=Query(tt1);
if (val<=mid+1){
ans=mid;
r=mid-1;
}
else l=mid+1;
}
//cerr<<ans<<'\n';
l=ans+1,r=sz(gr)-1;
int ano=r;
while (l<=r){
int mid=(l+r)/2;
vector<int>tt;
for1(j,0,mid){
if (j==ans)continue;
for(auto v:gr[j]){
tt.pb(v);
}
}
tt.pb(i);
vector<int>tt1;
for1(j,1,n)use[j]=0;
for(auto v:tt){
use[v]=1;
}
for1(j,1,n){
tt1.pb(use[j]);
}
int val=Query(tt1);
if (val<=mid+1){
ano=mid;
r=mid-1;
}
else l=mid+1;
}
vector<vector<int>>newgr;
for1(j,0,sz(gr)-1){
if (j==ano){
newgr[ans].pb(i);
for (auto v:gr[j]){
newgr[ans].pb(v);
}
}
else {
newgr.pb(gr[j]);
}
}
gr.swap(newgr);
continue;
}
}
Answer(gr[0]);
}
/*signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("temp.INP","r",stdin);
//freopen(".OUT","w",stdout);
judge.init();
Solve(judge.N);
judge.end();
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
288 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
288 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |