Submission #649607

#TimeUsernameProblemLanguageResultExecution timeMemory
649607PoonYaPat도서관 (JOI18_library)C++14
0 / 100
58 ms208 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; int query(vector<int> x) { bool check=false; for (int i=0; i<x.size(); ++i) if (x[i]) check=true; if (check) return Query(x); else return -1; } void Solve(int n) { int now=-1,pre=-1,ed; vector<int> test,ans; for (int i=0; i<n; ++i) test.push_back(1); for (int i=0; i<n; ++i) { test[i]=0; if (Query(test)==1) { if (now==-1) now=i; else ed=i; } test[i]=1; } int cnt=0; ans.push_back(now+1); while (now!=ed) { ++cnt; assert(cnt<100000); int l=0, r=n-1; while (l<r) { int mid=(l+r)/2; for (int i=0; i<n; ++i) { if (i==pre) test[i]=0; else if (i>=mid+1 && i<=r) test[i]=1; else test[i]=0; } int k1=query(test); test[now]=1-test[now]; int k2=query(test); if (k1==k2) l=mid+1; else r=mid; } ans.push_back(r+1); pre=now; now=r; } Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'int query(std::vector<int>)':
library.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for (int i=0; i<x.size(); ++i) if (x[i]) check=true;
      |                   ~^~~~~~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:26:12: warning: 'ed' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |  while (now!=ed) {
      |         ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...