Submission #1138714

#TimeUsernameProblemLanguageResultExecution timeMemory
1138714fryingducLibrary (JOI18_library)C++20
100 / 100
127 ms508 KiB
#include "bits/stdc++.h" #include "library.h" using namespace std; #ifdef duc_debug #include "bits/debug.h" #else #define debug(...) #endif const int maxn = 1005; int N; int Ask(vector<int> ask) { vector<int> dark(N); for(auto i:ask) { dark[i - 1] = 1; } return Query(dark); } void Solve(int n) { if(n == 1) { Answer({1}); return; } N = n; int outmost = 0; for(int i = 1; i <= n; ++i) { vector<int> t; for(int j = 1; j <= n; ++j) { if(i == j) continue; t.push_back(j); } if(Ask(t) == 1) { outmost = i; break; } } vector<int> res(1, outmost); vector<bool> used(n + 1); used[outmost] = 1; int now = outmost; for(int i = 2; i <= n; ++i) { vector<int> rem; for(int j = 1; j <= n; ++j) { if(used[j]) continue; rem.push_back(j); } int l = 0, r = (int)rem.size() - 1; int cur = -1; while(l <= r) { int mid = (l + r) >> 1; vector<int> hehe(rem.begin(), rem.begin() + mid + 1); int x = Ask(hehe); debug(hehe); hehe.push_back(now); int y = Ask(hehe); if(x == y) { cur = rem[mid]; r = mid - 1; } else { l = mid + 1; } } res.push_back(cur); used[cur] = 1; now = cur; } // debug(res); Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...