Submission #98927

#TimeUsernameProblemLanguageResultExecution timeMemory
98927jangwonyoungHidden Sequence (info1cup18_hidden)C++14
100 / 100
12 ms408 KiB
#include<bits/stdc++.h> #include "grader.h" using namespace std; int n,k; vector<int>p,q; void add(vector<int>& v,int x,int y){ for(int i=0; i<x ;i++) v.push_back(y); } int ask(vector<int>&v){ int res=isSubsequence(v); p.clear();q.clear(); return res; } int cnt=0; int a[201]; vector<int>findSequence(int N){ n=N;k=n/2+1; add(p,k,0); if(ask(p)){ for(int i=1; i<=k ;i++){ add(p,i,1);if(ask(p)) cnt=n-i; } } else{ for(int i=1; i<=k ;i++){ add(p,i,0);if(ask(p)) cnt=i; } } int sum=0; for(int i=0; i<cnt ;i++){ for(int j=1; j+sum+cnt<=n ;j++){ add(p,sum+j,1);add(p,cnt-i,0); add(q,i+1,0);add(q,n-cnt-sum-j+1,1); int res; if(p.size()>q.size()) res=1-ask(q); else res=ask(p); if(res) a[i]=j; else break; } sum+=a[i]; } a[cnt]=n-sum-cnt; vector<int>ans; for(int i=0; i<=cnt ;i++){ if(i!=0) ans.push_back(0); for(int j=1; j<=a[i] ;j++) ans.push_back(1); } return ans; }

Compilation message (stderr)

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