# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895330 | borisAngelov | Hidden Sequence (info1cup18_hidden) | C++17 | 5 ms | 976 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;
int countDigits(int digit, int n)
{
vector<int> v;
v.push_back(digit);
int cnt = 1;
while (cnt <= n)
{
if (isSubsequence(v) == false)
{
return cnt - 1;
}
v.push_back(digit);
++cnt;
}
return n;
}
vector<int> findSequence(int n)
{
int cnt0 = countDigits(0, n);
int cnt1 = n - cnt0;
vector<int> sequence;
for (int i = 0; i < n; ++i)
{
if (cnt0 == 0)
{
sequence.push_back(1);
continue;
}
if (cnt1 == 0)
{
sequence.push_back(0);
continue;
}
vector<int> curr;
for (int j = 0; j < sequence.size(); ++j)
{
curr.push_back(sequence[j]);
}
curr.push_back(0);
for (int j = 1; j <= cnt1; ++j)
{
curr.push_back(1);
}
if (isSubsequence(curr) == true)
{
sequence.push_back(0);
--cnt0;
}
else
{
sequence.push_back(1);
--cnt1;
}
}
return sequence;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |