Submission #96498

#TimeUsernameProblemLanguageResultExecution timeMemory
96498dnassHidden Sequence (info1cup18_hidden)C++14
100 / 100
9 ms404 KiB
#include <cstdio> #include <vector> #include <ctime> #include <cstdlib> #include "grader.h" using namespace std; int n; int halfp; int ones = -1, zeros = -1; int onesones, zeroszeros; vector<int> findSequence (int N){ n = N; halfp = (n/2)+1; vector<int> half_ones; for(int i=1;i<=halfp;i++){ half_ones.push_back(1); if(!isSubsequence(half_ones)){ ones = i-1; break; } } if(ones!=-1){ zeros = n-ones; }else{ vector<int> half_zeros; for(int i=1;i<=halfp;i++){ half_zeros.push_back(0); if(!isSubsequence(half_zeros)){ zeros = i-1; break; } } ones = n-zeros; } onesones = ones; zeroszeros = zeros; vector<int> ans; if(ones==n){ for(int i=0;i<n;i++) ans.push_back(1); }else if(zeros==n){ for(int i=0;i<n;i++) ans.push_back(0); }else{ while(onesones>0&&zeroszeros>0){ //printf("o:%d z:%d\n", onesones, zeroszeros); vector<int> subs0; for(int i=0;i<zeros-zeroszeros+1;i++) subs0.push_back(0); for(int i=0;i<onesones;i++) subs0.push_back(1); vector<int> subs1; for(int i=0;i<ones-onesones+1;i++) subs1.push_back(1); for(int i=0;i<zeroszeros;i++) subs1.push_back(0); if((int)subs0.size()<=halfp){ if(isSubsequence(subs0)){ ans.push_back(0); zeroszeros--; }else{ ans.push_back(1); onesones--; } }else{ if(isSubsequence(subs1)){ ans.push_back(1); onesones--; }else{ ans.push_back(0); zeroszeros--; } } } if(onesones==0){ for(int i=0;i<zeroszeros;i++) ans.push_back(0); }else if(zeroszeros==0){ for(int i=0;i<onesones;i++) 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...