Submission #1079933

#TimeUsernameProblemLanguageResultExecution timeMemory
1079933vjudge1Library (JOI18_library)C++17
100 / 100
223 ms600 KiB
#include "library.h" #include <bits/stdc++.h> #define taskname "" #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define i64 long long #define isz(x) (int)x.size() using namespace std; void Solve(int n) { if (n == 1) { Answer({1}); return; } if (n == 2) { Answer({1, 2}); return; } int st = -1; vector<int> vis(n, 1); for (int i = 0; i < n; ++i) { vis[i] = false; if (Query(vis) == 1) { st = i; break; } vis[i] = true; } vector<int> res = {st + 1}; vector<int> left; for (int i = 0; i < n; ++i) if (i != st) left.emplace_back(i); for (int i = 1; i < n; ++i) { int l = 0, r = isz(left); while (l + 1 < r) { int mid = (l + r) >> 1; int comp1, comp2; vis.assign(n, 0); for (int j = l; j < mid; ++j) vis[left[j]] = true; comp1 = Query(vis); vis[st] = true; comp2 = Query(vis); if (comp1 == comp2) r = mid; else l = mid; } int nst = left[l]; st = nst; res.emplace_back(st + 1); left.erase(left.begin() + l); } Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...