Submission #512860

#TimeUsernameProblemLanguageResultExecution timeMemory
512860Carmel_Ab1Hidden Sequence (info1cup18_hidden)C++17
59 / 100
8 ms332 KiB
#include<bits/stdc++.h> #include "grader.h" #define pb push_back using namespace std; typedef vector<int>vi; bool ask(vi v){return isSubsequence(v);} int c0=0,c1=0; vi buildL(int n){ int cur1=c1,cur0=c0; vi ans; while(ans.size()!=n){ if(cur1>cur0){ vi v; for(int x:ans) v.pb(x); v.pb(1); for(int i=0; i<cur0; i++) v.pb(0); if(ask(v)) ans.pb(1),cur1--; else ans.pb(0),cur0--; } else{ vi v; for(int x:ans) v.pb(x); v.pb(0); for(int i=0; i<cur1; i++) v.pb(1); if(ask(v)) ans.pb(0),cur0--; else ans.pb(1),cur1--; } } return ans; } vi buildR(int n){ int cur1=c1,cur0=c0; vi ans; while(ans.size()!=n){ if(cur1>cur0){ vi v=vi(cur0,0); v.pb(1); for(int x:ans) v.pb(x); if(ask(v)) ans.insert(ans.begin(),1),cur1--; else ans.insert(ans.begin(),0),cur0--; } else{ vi v=vi(cur1,1); v.pb(0); for(int x:ans) v.pb(x); if(ask(v)) ans.insert(ans.begin(),0),cur0--; else ans.insert(ans.begin(),1),cur1--; } } return ans; } vi findSequence (int n){ for(int i=1; ; i++){ vi all1=vi(i,1); vi all0=vi(i,0); if(!ask(all1)){ c1=i-1; c0=n-c1; break; } if(!ask(all0)){ c0=i-1; c1=n-c0; break; } } vi L=buildL((n+1)/2),R=buildR(n/2); vi ans; for(int x:L)ans.pb(x); for(int x:R)ans.pb(x); return ans; }

Compilation message (stderr)

hidden.cpp: In function 'vi buildL(int)':
hidden.cpp:15:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     while(ans.size()!=n){
      |           ~~~~~~~~~~^~~
hidden.cpp: In function 'vi buildR(int)':
hidden.cpp:47:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     while(ans.size()!=n){
      |           ~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...