# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130202 | RockyB | Library (JOI18_library) | C++17 | 3099 ms | 2876 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;
const int MAXN = (int)1e5 + 7;
vector <int> g[MAXN];
void Solve(int N) {
vector <int> A(N);
for (int i = 1; i <= N; i++) {
for (int j = i + 1; j <= N; j++) {
A[i - 1] = A[j - 1] = 1;
int cnt = Query(A);
if (cnt == 1) {
g[i].push_back(j);
g[j].push_back(i);
}
A[i - 1] = A[j - 1] = 0;
}
}
int v = -1, p = -1;
vector <int> ans;
for (int i = 1; i <= N; i++) {
// cerr << i << " -> " << g[i].size() << endl;
if (g[i].size() <= 1) {
v = i;
break;
}
}
while (ans.size() < N) {
ans.push_back(v);
for (auto it : g[v]) {
if (it != p) {
p = v;
v = it;
break;
}
}
}
// for (auto it : ans) cerr << it << ' ';
Answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |