# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199220 | Bagritsevich_Stepan | Hidden Sequence (info1cup18_hidden) | C++14 | 56 ms | 248 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 "/Users/stdc++.h"
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define mp make_pair
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair < int, int >
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;
typedef long double ld;
const int INF = 2e9;
const ll BIG_INF = 1e18;
const ll MOD = 1e9 + 7;
const int maxn = 1e5 + 5;
vector < int > findSequence(int n) {
const int maxlen = n / 2 + 1;
int num = 1;
vector < int > seq;
while (sz(seq) < maxlen && isSubsequence(seq))
seq.pb(num);
if (!isSubsequence(seq)) seq.pop_back();
if (sz(seq) == maxlen) {
num ^= 1;
seq.clear();
while (isSubsequence(seq))
seq.pb(num);
seq.pop_back();
}
int cnt = 0, cnt_nums = sz(seq);
vector < int > res(n, num ^ 1);
for (int i = 0; i < cnt_nums; i++) {
while (sz(seq) <= maxlen && isSubsequence(seq)) {
seq.insert(seq.begin(), num ^ 1);
cnt++;
}
seq.erase(seq.begin());
cnt--;
vector < int > rev_seq(i + 1, num);
while (sz(rev_seq) <= maxlen && isSubsequence(rev_seq))
rev_seq.pb(num ^ 1);
rev_seq.pop_back();
res[max(cnt, n - cnt_nums - (sz(rev_seq) - (i + 1))) + i] = num;
seq.pop_back();
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |