# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45212 | reality | Hidden Sequence (info1cup18_hidden) | C++17 | 6 ms | 640 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 "grader.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int get(string str) {
vi cnt;
for (auto it : str)
cnt.pb(it - '0');
return isSubsequence(cnt);
}
vector < int > findSequence (int N) {
const int lim = (N / 2) + 1;
string str = "";
int w = 1;
while (str.length() < lim && get(str + "0")) str += "0";
if (str.length() == lim) {
w = 0;
str = "";
while (get(str + "1"))
str += "1";
}
vector < string > S[2];
S[0].pb("");
S[1].pb("");
for (int i = 1;i <= N;++i)
S[0].pb(S[0].back() + "0"),S[1].pb(S[1].back() + "1");
const int SZ = str.length();
string answer = "";
int l = 0,r = N - SZ;
for (int i = 0;i <= SZ;++i) {
int ok = 1;
while (ok && r > 0) {
if (SZ - i + l <= i + r) {
if (get(S[w][l + 1] + S[w^1][SZ - i]))
answer += w + '0',++l,--r;
else
ok = 0;
} else {
if (!get(S[w^1][i + 1] + S[w][r]))
answer += w + '0',++l,--r;
else
ok = 0;
}
}
if (i != SZ)
answer += (1 - w) + '0';
}
vi ans;
for (auto it : answer)
ans.pb(it - '0');
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |