# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1235703 | Aisha | Hidden Sequence (info1cup18_hidden) | C++20 | 17 ms | 416 KiB |
#include "bits/stdc++.h"
#include "grader.h"
using namespace std;
vector <int> findSequence(int n) {
vector <int> ans;
int cnta = 0, cntb = 0;
int a = 0, b = 1;
vector <int> q;
for (int i = 1; i <= n / 2; i ++) {
q.push_back(a);
bool ok = isSubsequence(q);
if (ok) cnta ++;
else break;
}
if (cnta == n / 2) {
a = 1; b = 0; cnta = 0;
q.clear();
for (int i = 1; i <= n / 2; i ++) {
q.push_back(a);
bool ok = isSubsequence(q);
if (ok) cnta ++;
else break;
}
}
// cout << a << ' ' << b << endl;
cntb = n - cnta;
// cout << cnta << ' ' << cntb << endl;
q.clear();
int x = 0; q.push_back(a);
while (cntb > 0) {
int k = 0;
for (int i = 1; i <= cntb; i ++) {
q.push_back(b);
bool ok = isSubsequence(q);
if (ok) k ++;
else break;
}
// cout << k << endl;
for (int i = 1; i <= cntb - k; i ++) ans.push_back(b);
if (x == cnta) break;
ans.push_back(a);
x ++;
q.clear();
for (int i = 1; i <= x; i ++) q.push_back(a);
cntb = k;
}
while (x < cnta) ans.push_back(a), x ++;
while (cntb) ans.push_back(b), cntb --;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |