# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410871 | nichke | Hidden Sequence (info1cup18_hidden) | C++14 | 5 ms | 200 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;
bool isSubsequence(vector<int> vi);
int cnt[2];
int done[2];
vector<int> findSequence(int N) {
vector<int> ans(N);
vector<int> tmp;
for (int i = 0; i < N; i++) {
tmp.push_back(0);
if (!isSubsequence(tmp)) break;
cnt[0]++;
}
tmp.clear();
for (int i = 0; i < N; i++) {
tmp.push_back(1);
if (!isSubsequence(tmp)) break;
cnt[1]++;
}
for (int i = N - 1; i >= 0; i--) {
if (!cnt[0]) {
ans[i] = 1; cnt[1]--;
continue;
}
if (!cnt[1]) {
ans[i] = 0; cnt[0]--;
continue;
}
int bt = 1;
if (cnt[0] + done[1] > cnt[1] + done[0]) {
bt ^= 1;
}
tmp.clear();
for (int j = 0; j < cnt[bt ^ 1]; j++) tmp.push_back(bt ^ 1);
for (int j = 0; j < done[bt]; j++) tmp.push_back(bt);
ans[i] = (!isSubsequence(tmp)) ^ bt;
done[ans[i]]++; cnt[ans[i]]--;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |