# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
940466 | groshi | Library (JOI18_library) | C++17 | 210 ms | 704 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;
int zaliczony[2000];
/*int Query(vector<int> pyt)
{
for(int i=0;i<pyt.size();i++)
cout<<pyt[i]<<" ";
int wynik;
cin>>wynik;
return wynik;
}
void Answer(vector<int> wynik)
{
cout<<"wynik - > ";
for(int i=0;i<wynik.size();i++)
cout<<wynik[i]<<" ";
}*/
void Solve(int n)
{
if(n==1)
{
Answer({1});
return;
}
vector<int> pytaj;
for(int i=1;i<=n;i++)
pytaj.push_back(1);
int ost;
vector<int> wynik;
for(int i=0;i<n;i++)
{
pytaj[i]=0;
if(Query(pytaj)==1)
{
ost=i;
wynik.push_back(i+1);
zaliczony[i]=1;
break;
}
pytaj[i]=1;
}
for(int i=1;i<n;i++)
{
vector<int> niema;
for(int j=0;j<n;j++)
if(zaliczony[j]==0)
niema.push_back(j);
int pocz=0,kon=niema.size(),sre,ostd=0;
while(pocz<kon)
{
//cout<<i<<": "<<pocz<<" "<<kon<<"\n";
sre=(pocz+kon)/2;
vector<int> pytaj;
for(int j=0;j<n;j++)
pytaj.push_back(0);
for(int j=0;j<=sre;j++)
pytaj[niema[j]]=1;
int essa=Query(pytaj);
pytaj[ost]=1;
if(Query(pytaj)==essa)
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
wynik.push_back(niema[ostd]+1);
zaliczony[niema[ostd]]=1;
ost=niema[ostd];
}
Answer(wynik);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |