# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963362 | biank | Hidden Sequence (info1cup18_hidden) | C++14 | 5 ms | 1208 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 <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define sz(x) int(x.size())
bool query(int k, vector<int> s, int c) {
s.push_back(k ^ 1);
while (c--) s.push_back(k);
return isSubsequence(s);
}
vector<int> findSequence(int N) {
int l = 0, r = N + 1;
vector<int> s;
while (l + 1 < r) {
int m = (l + r) / 2;
while (sz(s) > m) s.pop_back();
while (sz(s) < m) s.push_back(0);
if (isSubsequence(s)) {
l = m;
} else {
r = m;
}
}
int n = l, m = N - l;
int k = 0;
if (n > m) swap(n, m), k ^= 1;
vector<int> ans;
int i = 0, j = 0;
while (i < n || j < m) {
if (i >= n || (j < m && query(k, ans, n - i))) {
ans.push_back(k ^ 1);
j++;
} else {
ans.push_back(k);
i++;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |