Submission #153994

#TimeUsernameProblemLanguageResultExecution timeMemory
153994karmaLibrary (JOI18_library)C++14
100 / 100
538 ms456 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); swap(s[cur], s[s.size() - 1]); s.pop_back(); 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); swap(s[low], s[s.size() - 1]); s.pop_back(); } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...