# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1126159 | qrn | Hidden Sequence (info1cup18_hidden) | C++20 | 8 ms | 424 KiB |
#include<bits/stdc++.h>
#include "grader.h"
#define pb push_back
#define endl "\n"
#define ALL(x) x.begin(), x.end()
using namespace std;
vector<int> findSequence (int N) {
int initN = N, l = 0, r = N + 1, numzero = 0;
vector<int> seq;
while(l <= r) {
int mid = (l + r) / 2;
for(int i = 0; i < mid; i++) seq.pb(0);
if(isSubsequence(seq)) {
numzero = mid;
l = mid + 1;
} else {
r = mid - 1;
}
seq.clear();
}
N -= numzero;
vector<int>ans;
for(int cnt = 0; cnt <= numzero; cnt++) {
int l = 0, r = N + 1, numone = 0;
while(l <= r) {
int mid = (l + r) / 2;
for(int i = 0; i < cnt; i++) seq.pb(0);
for(int i = 0; i < mid; i++) seq.pb(1);
for(int i = cnt; i < numzero; i++) seq.pb(0);
if(isSubsequence(seq)) {
numone = mid;
l = mid + 1;
} else{
r = mid - 1;
}
seq.clear();
}
for(int i = 0; i < numone; i++) {
ans.pb(1);
}
ans.pb(0);
}
if((int)ans.size() != initN) {
ans.pop_back();
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |