# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
266664 | Toirov_Sadi | Library (JOI18_library) | C++17 | 0 ms | 0 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>
using namespace std;
void Solve(int N){
vector<int> res;
res = {1};
set<int> p;
for(int i = 2; i <= N; i ++) p.insert(i);
vector<int> q(N, 0);
auto fll = [&](vector<int> &t){
int good = 1;
while(good == 1){
int last = res.back();
int nxt = -1;
good = 0;
for(auto x: p){
if(good == 1) break;
q[last - 1] = 1;
q[x - 1] = 1;
if(Query(q) == 1){
nxt = x;
good = 1;
}
q[last - 1] = 0;
q[x - 1] = 0;
}
if(good == 1){
p.erase(nxt);
res.push_back(nxt);
}
}
};
fll(res);
reverse(res.begin(), res.end());
fll(res);
Answer(res);
}