Submission #61721

#TimeUsernameProblemLanguageResultExecution timeMemory
61721kjp4155Library (JOI18_library)C++17
100 / 100
686 ms700 KiB
#include <cstdio> #include <vector> #include "library.h" using namespace std; #define sz(x) (int) x.size() bool vis[1050]; int L; vector<int> rans, lans; void Solve(int N) { if( N == 1 ){ lans.push_back(1); Answer(lans); return; } // find leftmost for(int i=1;i<=N;i++){ vector<int> qv; for(int j=1;j<=N;j++){ qv.push_back(1); } qv[i-1] = 0; int res1 = Query(qv); if( sz(lans) == 0 && res1 == 1 ){ lans.push_back(i); vis[i] = 1; } else if( sz(rans) == 0 && res1 == 1 ){ rans.push_back(i); vis[i] = 1; } } vector<int> qv(N); // find left while( sz(lans) + sz(rans) < N ){ int L = lans[sz(lans)-1]; int R = rans[sz(rans)-1]; int lt = 0, rt = 0; for(int k=0;k<10;k++){ for(auto& e : qv) e = 0; for(int i=1;i<=N;i++)if(!vis[i]){ if( i & (1<<k) ) qv[i-1] = 1; } bool all_zero = true, all_one = true; for(auto e : qv) if( e != 0 ) all_zero = false; for(auto e : qv) if( e != 1 ) all_one = false; if( all_zero ) continue; int res1 = Query(qv); qv[L-1] = 1; int res2 = Query(qv); qv[L-1] = 0; qv[R-1] = 1; int res3 = Query(qv); if( res1 == res2 ) lt |= (1<<k); if( res1 == res3 ) rt |= (1<<k); } lans.push_back(lt); vis[lt] = 1; if( lt != rt ){ rans.push_back(rt); vis[rt] = 1; } } for(int i=sz(rans)-1;i>=0;i--) lans.push_back(rans[i]); //for(auto e : ans ) printf("%d ",e); Answer(lans); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:52:26: warning: variable 'all_one' set but not used [-Wunused-but-set-variable]
    bool all_zero = true, all_one = true;
                          ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...