# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963368 | biank | Hidden Sequence (info1cup18_hidden) | C++14 | 5 ms | 1460 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())
int query(int k, int a, int b) {
vector<int> s(a, k);
while (b--) s.push_back(k ^ 1);
return k ^ 1 ^ isSubsequence(s);
}
vector<int> findSequence(int N) {
vector<int> s0, s1;
int n = 0, k = -1;
while (true) {
s0.push_back(0);
if (!isSubsequence(s0)) {
k = 0;
break;
}
s1.push_back(1);
if (!isSubsequence(s1)) {
k = 1;
break;
}
n++;
}
int m = N - n;
vector<int> ans;
int i = 0, j = 0;
while (i < n && j < m) {
int x = -1;
if (i + m - j < j + n - i) {
x = query(k, i + 1, m - j);
} else {
x = query(k ^ 1, j + 1, n - i);
}
if (x == k) i++;
else j++;
ans.push_back(x);
}
while (i < n) ans.push_back(k), i++;
while (j < m) ans.push_back(k ^ 1), j++;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |