Submission #139845

#TimeUsernameProblemLanguageResultExecution timeMemory
139845zoooma13Library (JOI18_library)C++14
100 / 100
570 ms408 KiB
#include "bits/stdc++.h" #include "library.h" using namespace std; void Solve(int N) { if(N == 1){ Answer({1}); return; } vector <int> still(N); iota(still.begin() ,still.end() ,0); int chnd; for(int i=0; i<N; i++){ vector <int> M(N ,1); M[i] = 0; if(Query(M) == 1) chnd = i; } still.erase(find(still.begin() ,still.end() ,chnd)); vector <int> res{chnd+1}; for(int i=1; i<N; i++){ int st = 0 ,en = still.size()-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> M(N ,0); for(int i=0; i<=mid; i++) M[still[i]] = 1; int c = Query(M); M[chnd] = 1; if(c == Query(M)) en = mid-1; else st = mid+1; } chnd = still[st]; res.push_back(chnd+1); still.erase(still.begin()+st); } Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...