# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
679142 | Ronin13 | Library (JOI18_library) | C++14 | 487 ms | 304 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 <cstdio>
#include <vector>
#include "library.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec;
vector <int> def;
int n;
int get(int x){
int l = -1, r = vec.size() - 1;
while(l + 1 < r){
def.assign(n, 0);
int mid = (l + r) / 2;
vector <int> qv;
for(int j = 0; j <= mid; j++){
qv.pb(vec[j]);
}
for(int to : qv) def[to - 1] = 1;
int u = Query(def);
def[x - 1] = 1;
int v = Query(def);
if(u == v) r = mid;
else l = mid;
}
return vec[r];
}
void Solve(int N)
{
n = N;
if(n == 1){
Answer({1});
return;
}
for(int i = 1; i <= n; i++)
vec.pb(i), def.pb(0);
vector <int> ans;
for(int i = 1; i <= n; i++){
vector <int> qv;
for(int j = 0; j < i - 1; j++) qv.pb(vec[j]);
for(int j = i; j < vec.size(); j++) qv.pb(vec[j]);
for(int to : qv)
def[to - 1] = 1;
int l = Query(def);
def.assign(n, 0);
if(l == 1){
ans.pb(i);
break;
}
}
//cout << ans.back();
for(int j = 1; j < n; j++){
for(int x = 0; x < vec.size(); x++){
if(vec[x] == ans.back()){
int pos = x;
while(pos < vec.size() - 1) swap(vec[pos], vec[pos + 1]), pos++;
vec.pop_back();
break;
}
}
ans.pb(get(ans.back()));
}
Answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |