Submission #98187

#TimeUsernameProblemLanguageResultExecution timeMemory
98187onjo0127Library (JOI18_library)C++11
100 / 100
521 ms512 KiB
#include <cstdio> #include <vector> #include "library.h" using namespace std; vector<int> M; void Solve(int N) { if(N == 1) { Answer(vector<int>(1, 1)); return; } int now; M = vector<int>(N, 1); for(int i=0; i<N; i++) { M[i] = 0; if(Query(M) == 1) now = i; M[i] = 1; } M = vector<int>(N, 0); vector<int> S, ans = {now + 1}; for(int i=0; i<N; i++) if(i != now) S.push_back(i); for(int i=0; i<N-1; i++) { int l = 0, r = N-i-1; while(l < r) { int m = l+r >> 1; for(int i=l; i<=m; i++) M[S[i]] = 1; int pr = Query(M); M[now] = 1; bool f = (pr != Query(M)); M[now] = 0; for(int i=l; i<=m; i++) M[S[i]] = 0; if(f) l = m+1; else r = m; } now = S[l]; ans.push_back(S[l] + 1); S.erase(S.begin() + l); } Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:26:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int m = l+r >> 1;
                     ~^~
library.cpp:22:25: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
  for(int i=0; i<N; i++) if(i != now) S.push_back(i);
                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...