# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261908 | thecodingwizard | Hidden Sequence (info1cup18_hidden) | C++11 | 56 ms | 256 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 qry(int zeroes, int ones, bool rev = false) {
vector<int> v;
for (int i = 0; i < zeroes; i++) {
v.push_back(0);
}
for (int j = 0; j < ones; j++) {
v.push_back(1);
}
if (rev) reverse(v.begin(), v.end());
return isSubsequence(v);
}
vector<int> findSequence (int N)
{
int numZeroes = 1, numOnes = 1;
for (; numZeroes <= N/2+1; numZeroes++) {
if (qry(numZeroes, 0)) {
continue;
} else {
break;
}
}
numZeroes--;
if (numZeroes == N/2+1) {
for (; numOnes <= N/2+1; numOnes++) {
if (qry(0, numOnes, true)) {
continue;
} else {
break;
}
}
numOnes--;
numZeroes = N - numOnes;
} else {
numOnes = N - numZeroes;
}
vector<int> ans;
int usedZeroes = 0;
for (int i = 0; i < numOnes; i++) {
int newZeroes = 0;
int numCanFit = 0;
for (int j = 1; j <= numZeroes - usedZeroes; j++) {
if (i+1 + j <= N/2+1) {
if (qry(i+1, j, true)) {
numCanFit++;
} else {
break;
}
} else {
numCanFit = -1;
if (qry(usedZeroes + j, numOnes - i)) {
newZeroes++;
} else {
break;
}
}
}
if (numCanFit != -1) {
newZeroes = (numZeroes - usedZeroes) - numCanFit;
}
for (int i = 0; i < newZeroes; i++) {
ans.push_back(0);
}
ans.push_back(1);
usedZeroes += newZeroes;
}
while ((int)ans.size() != N) {
ans.push_back(0);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |