Submission #434409

# Submission time Handle Problem Language Result Execution time Memory
434409 2021-06-21T08:43:43 Z Dymo Hidden Sequence (info1cup18_hidden) C++17
0 / 100
4 ms 200 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 200 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 200 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -