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> res;
if (N == 1) {
res = {1};
Answer(res);
}
else if (N == 2){
res = {1, 2};
Answer(res);
}
vector<int> M (N, 1);
int extremo = -1;
for (int i = 0; i < N; i++) {
M[i] = 0;
if (Query(M) == 1) {
extremo = i;
break;
}
M[i] = 1;
}
res.push_back(extremo+1);
M.assign(N, 0);
vector<bool> puesto(N, false);
puesto[extremo] = true;
int libro_izq = extremo;
while ((int)res.size() < N) {
for (int i = 0; i < N; i++) {
if (puesto[i]) continue;
M[libro_izq] = 1; M[i] = 1;
if (Query(M) == 1) {
res.push_back(i+1);
libro_izq = i;
break;
}
M[libro_izq] = 0; M[i] = 0;
}
}
Answer(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |