# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434409 | Dymo | Hidden Sequence (info1cup18_hidden) | C++17 | 4 ms | 200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |