# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260798 | arnold518 | Library (JOI18_library) | C++14 | 3027 ms | 376 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 "library.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1000;
int N;
vector<int> todo, T, ans;
void Solve(int _N)
{
N=_N;
for(int i=1; i<=N; i++) todo.push_back(i);
ans=vector<int>(N);
T=vector<int>(N, 1);
int now=0;
for(int j=0; j+1<todo.size(); j++)
{
int p=todo[j];
T[p-1]=0;
int q=Query(T);
if(q==1) now=p;
T[p-1]=1;
}
if(now==0) now=todo.back();
for(int j=0; j<todo.size(); j++) if(todo[j]==now)
{
todo.erase(todo.begin()+j);
break;
}
ans[0]=now;
for(int i=2; i<=N; i++)
{
T=vector<int>(N, 1);
for(auto it : todo) T[it-1]=0;
int now=0;
for(int j=0; j+1<todo.size(); j++)
{
int p=todo[j];
T[p-1]=1;
int q=Query(T);
if(q==1) now=p;
T[p-1]=0;
}
if(now==0) now=todo.back();
for(int j=0; j<todo.size(); j++) if(todo[j]==now)
{
todo.erase(todo.begin()+j);
break;
}
ans[i-1]=now;
}
Answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |