Submission #153993

#TimeUsernameProblemLanguageResultExecution timeMemory
153993karmaLibrary (JOI18_library)C++14
100 / 100
546 ms504 KiB
#include<bits/stdc++.h> #include "library.h" #define pb emplace_back #define ll long long using namespace std; const int N = int(2e3) + 7; vector<int> m, ans, s; int low, high, mid, cur; void Solve(int n) { if(n == 1) {Answer({1}); return;} m.resize(n, 1); s.resize(n); for(int i = 0; i < n; ++i) { m[i] = 0; if(Query(m) == 1) {cur = i; break;} m[i] = 1; } iota(s.begin(), s.end(), 0); ans.pb(cur + 1); s.erase(find(s.begin(), s.end(), cur)); while(s.size()) { low = 0, high = s.size() - 1; while(low <= high) { mid = (low + high) >> 1; fill(m.begin(), m.end(), 0); for(int i = 0; i <= mid; ++i) m[s[i]] = 1; int res = Query(m); m[cur] = 1; if(res == Query(m)) high = mid - 1; else low = mid + 1; } cur = s[low]; ans.pb(cur + 1); s.erase(find(s.begin(), s.end(), cur)); } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...