# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923206 | Ianis | Hidden Sequence (info1cup18_hidden) | C++17 | 2 ms | 856 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(a) int((a).size())
#define all(a) (a).begin(), (a).end()
vector<int> operator+(vector<int> dest, const vector<int> &src) {
for (auto &it : src)
dest.push_back(it);
return dest;
}
vector<int> rev(vector<int> v) {
reverse(all(v));
return v;
}
bool flipped;
int cnt[2], used[2];
vector<int> findSequence(int n) {
vector<int> pref, suff;
if (isSubsequence(vector(n / 2 + 1, 0)))
flipped = true;
for (int i = n / 2; i >= 1; i--) {
if (isSubsequence(vector<int>(i, flipped))) {
cnt[flipped] = i;
break;
}
}
cnt[!flipped] = n - cnt[flipped];
vector<int> ans;
while (int(ans.size()) < n) {
vector<int> s;
if (used[0] + cnt[1] - used[1] < used[1] + cnt[0] - used[0]) {
s = vector<int>(used[0] + 1, 0) + vector<int>(cnt[1] - used[1], 1);
if (isSubsequence(s)) ans.push_back(0);
else ans.push_back(1);
} else {
s = vector<int>(used[1] + 1, 1) + vector<int>(cnt[0] - used[0], 0);
if (isSubsequence(s)) ans.push_back(1);
else ans.push_back(0);
}
used[ans.back()]++;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |