Submission #434409

#TimeUsernameProblemLanguageResultExecution timeMemory
434409DymoHidden Sequence (info1cup18_hidden)C++17
0 / 100
4 ms200 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define pb push_back #define endl "\n" const ll maxn=2e5+10; const ll mod =998244353 ; const ll base=1e13; #include "grader.h" bool chk(ll dem,ll pre,ll i,ll nxt1,ll pre1,ll n) { ll pre0=pre+dem; ll nxt0=n-pre0-nxt1-pre1-1; vector<int> vt; if (pre0+nxt1+1<=(n)/2+1) { while (pre0--) vt.pb(0); vt.pb(1); while (nxt1--) vt.pb(1); } else { while (pre1--) vt.pb(1); vt.pb(1); while (nxt0--) vt.pb(0); } return isSubsequence(vt); } vector < int > findSequence (int N) { ll n=N; ll t=(n)/2+1; ll cnt0; ll cnt1; for (int j=1; j<=t; j++) { vector<int > vt(j,0); if (!isSubsequence(vt)) { cnt0=j-1; cnt1=n-cnt0; break; } vt=vector<int> (j,1); if (!isSubsequence(vt)) { cnt1=j-1; cnt0=n-cnt0; break; } } ll pre=0; vector<int> ans; for (int j=1;j<=cnt1;j++) { ll pre1=j-1; ll nxt1=cnt1-j; ll dem=1; while (dem+pre+cnt1<=n&&chk(dem,pre,j,nxt1,pre1,n)) { dem++; } dem--; pre+=dem; while (dem--) ans.pb(0); ans.pb(1); } ll cl=n-cnt1-pre; while (cl--) ans.pb(0); return ans; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:62:19: warning: 'cnt1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |     for (int j=1;j<=cnt1;j++)
      |                  ~^~~~~~
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...