# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388905 | denkendoemeer | Library (JOI18_library) | C++14 | 383 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n)
{
vector<int>v(n,1),viz(n,0),a;
if (n==1){
a={1};
Answer(a);
return ;
}
int i;
for(i=1;i<=n;i++){
v[i-1]--;
if (Query(v)==1){
a.push_back(i);
viz[i-1]=1;
break;
}
v[i-1]++;
}
while(a.size()<n){
vector<int>aux;
for(i=1;i<=n;i++)
if (viz[i-1]==0)
aux.push_back(i);
int st=0,dr=aux.size();
while(dr-st>1){
int mij=(st+dr)/2;
fill(v.begin(),v.end(),0);
for(i=0;i<mij;i++)
v[aux[i]-1]++;
int val=Query(v);
v[a.back()-1]++;
if (Query(v)==val)
dr=mij;
else
st=mij;
}
a.push_back(aux[st]);
viz[aux[st]-1]++;
}
Answer(a);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |