Submission #1022350

#TimeUsernameProblemLanguageResultExecution timeMemory
1022350gvancakHidden Sequence (info1cup18_hidden)C++11
0 / 100
1937 ms1984 KiB
#include<bits/stdc++.h> #include "grader.h" #define pb push_back using namespace std; vector < int > findSequence (int N) { vector < int > ans,v; int cnt1=0,cnt0=0; bool ok; int c0,c1,x; for (int i=1; i<=N/2+1; i++) v.push_back(0); ok=isSubsequence (v); if (ok==1){ x=N/2+1; cnt1=0; while (1){ if (x==0) break; v.clear(); for (int i=1; i<=x; i++) v.push_back(1); ok=isSubsequence (v); if (ok==1){ cnt1=x; break; } x--; } if (cnt1==0){ for (int i=1; i<=N; i++) ans.pb(0); return ans; } if (cnt1==N){ for (int i=1; i<=N; i++) ans.pb(1); return ans; } cnt0=N-cnt1; //1<0 c0=0; c1=1; while (c1<=cnt1){ v.clear(); if (c1+cnt0-c0<=N/2+1){ for (int i=1; i<=c1; i++) v.push_back(1); for (int i=1; i<=cnt0-c0; i++) v.push_back(0); ok=isSubsequence (v); if (ok==0){ ans.push_back(0); c0++; } else{ ans.push_back(1); c1++; } } else{ // c1+1+cnt0-ind+1<=N/2+1 for (int i=1; i<=min(c0+1,cnt0); i++) v.push_back(0); for (int i=1; i<=cnt1-c1+1; i++) v.push_back(1); ok=isSubsequence (v); if (ok==0){ ans.push_back(1); c1++; } else{ ans.push_back(0); c0++; } } } x=ans.size(); for (int i=x+1; i<=N; i++) ans.push_back(0); } else{ x=N/2+1; cnt0=0; while (1){ if (x==0) break; v.clear(); for (int i=1; i<=x; i++) v.push_back(1); ok=isSubsequence (v); if (ok==1){ cnt0=x; break; } x--; } if (cnt0==0){ for (int i=1; i<=N; i++) ans.pb(1); return ans; } if (cnt0==N){ for (int i=1; i<=N; i++) ans.pb(0); return ans; } cnt1=N-cnt0; //0<1 c0=1; c1=0; while (c0<=cnt0){ v.clear(); if (c0+cnt1-c1<=N/2+1){ for (int i=1; i<=c0; i++) v.push_back(0); for (int i=1; i<=cnt1-c1; i++) v.push_back(1); ok=isSubsequence (v); if (ok==1){ ans.push_back(0); c0++; } else{ ans.push_back(1); c1++; } } else{ // c1+1+cnt0-ind+1<=N/2+1 for (int i=1; i<=min(c1+1,cnt1); i++) v.push_back(1); for (int i=1; i<=cnt0-c0+1; i++) v.push_back(0); ok=isSubsequence (v); if (ok==1){ ans.push_back(1); c1++; } else{ ans.push_back(0); c0++; } } } x=ans.size(); for (int i=x+1; i<=N; i++) ans.push_back(1); } return ans; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:18:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |       if (x==0) break; v.clear();
      |       ^~
hidden.cpp:18:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |       if (x==0) break; v.clear();
      |                        ^
hidden.cpp:27:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   27 |    for (int i=1; i<=N; i++) ans.pb(0); return ans;
      |    ^~~
hidden.cpp:27:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |    for (int i=1; i<=N; i++) ans.pb(0); return ans;
      |                                        ^~~~~~
hidden.cpp:30:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   30 |    for (int i=1; i<=N; i++) ans.pb(1); return ans;
      |    ^~~
hidden.cpp:30:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |    for (int i=1; i<=N; i++) ans.pb(1); return ans;
      |                                        ^~~~~~
hidden.cpp:69:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   69 |       if (x==0) break; v.clear();
      |       ^~
hidden.cpp:69:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   69 |       if (x==0) break; v.clear();
      |                        ^
hidden.cpp:78:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   78 |    for (int i=1; i<=N; i++) ans.pb(1); return ans;
      |    ^~~
hidden.cpp:78:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   78 |    for (int i=1; i<=N; i++) ans.pb(1); return ans;
      |                                        ^~~~~~
hidden.cpp:81:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   81 |    for (int i=1; i<=N; i++) ans.pb(0); return ans;
      |    ^~~
hidden.cpp:81:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   81 |    for (int i=1; i<=N; i++) ans.pb(0); return ans;
      |                                        ^~~~~~
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...