Submission #136967

#TimeUsernameProblemLanguageResultExecution timeMemory
136967Osama_AlkhodairyLibrary (JOI18_library)C++17
100 / 100
518 ms452 KiB
#include <bits/stdc++.h> #include "library.h" //~ #include "grader.cpp" using namespace std; void Solve(int N){ if(N == 1){ Answer({1}); return; } int start = 0; vector <int> ans; while(start < N){ vector <int> q(N, 1); q[start] = 0; if(Query(q) == 1){ ans.push_back(start); break; } start++; } vector <int> all; for(int i = 0 ; i < N ; i++){ if(i != ans.back()) all.push_back(i); } while(all.size()){ int l = 0, r = (int)all.size() - 1; while(l <= r){ int mid = (l + r) / 2; vector <int> q(N, 0); for(int i = 0 ; i <= mid ; i++){ q[all[i]] = 1; } int x = Query(q); q[ans.back()] = 1; if(Query(q) == x) r = mid - 1; else l = mid + 1; } ans.push_back(all[l]); swap(all[l], all.back()); all.pop_back(); } for(auto &i : ans) i++; Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...