# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1126166 | qrn | Hidden Sequence (info1cup18_hidden) | C++20 | 6 ms | 420 KiB |
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> findSequence(int N) {
int initN = N, numZero = 0;
vector<int> seq, ans;
int l = 0, r = N;
while (l <= r) {
int mid = (l + r) / 2;
seq.assign(mid, 0);
if (isSubsequence(seq)) {
numZero = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
N -= numZero;
for (int zcnt = 0; zcnt <= numZero; zcnt++) {
int numOne = 0;
l = 0, r = N;
while (l <= r) {
int mid = (l + r) / 2;
seq.clear();
seq.insert(seq.end(), zcnt, 0);
seq.insert(seq.end(), mid, 1);
seq.insert(seq.end(), numZero - zcnt, 0);
if (isSubsequence(seq)) {
numOne = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
ans.insert(ans.end(), numOne, 1);
if (zcnt < numZero) {
ans.push_back(0);
}
N -= numOne;
}
ans.insert(ans.end(), N, 1);
if ((int)ans.size() > initN) {
ans.resize(initN);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |