# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98187 | onjo0127 | Library (JOI18_library) | C++11 | 521 ms | 512 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"
using namespace std;
vector<int> M;
void Solve(int N) {
if(N == 1) {
Answer(vector<int>(1, 1));
return;
}
int now;
M = vector<int>(N, 1);
for(int i=0; i<N; i++) {
M[i] = 0;
if(Query(M) == 1) now = i;
M[i] = 1;
}
M = vector<int>(N, 0);
vector<int> S, ans = {now + 1};
for(int i=0; i<N; i++) if(i != now) S.push_back(i);
for(int i=0; i<N-1; i++) {
int l = 0, r = N-i-1;
while(l < r) {
int m = l+r >> 1;
for(int i=l; i<=m; i++) M[S[i]] = 1;
int pr = Query(M);
M[now] = 1;
bool f = (pr != Query(M));
M[now] = 0;
for(int i=l; i<=m; i++) M[S[i]] = 0;
if(f) l = m+1;
else r = m;
}
now = S[l];
ans.push_back(S[l] + 1);
S.erase(S.begin() + l);
}
Answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |