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