# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96483 | ASG1065 | Hidden Sequence (info1cup18_hidden) | C++14 | 11 ms | 376 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"
std::vector <int> findSequence(int n)
{
std::vector <int> ans;
std::vector <int> ones;
std::vector<int> zeros;
int zeroct;
int onect;
for (int i = 1; i <= std::floor(n/2)+1; ++i)
{
zeros.push_back(0);
if (!isSubsequence(zeros))
{
zeroct=i-1;
onect=n-zeroct;
break;
}
ones.push_back(1);
if (!isSubsequence(ones))
{
onect=i-1;
zeroct=n-onect;
break;
}
}
int usedzeros = 0;
int usedones = 0;
for (int i = 0; i < n; ++i)
{
std::vector<int> guess;
if (usedzeros+1+onect-usedones <= usedones+1+zeroct-usedzeros)
{
for (int j = 0; j < usedzeros+1; ++j)
{
guess.push_back(0);
}
for (int j = 0; j < onect-usedones; ++j)
{
guess.push_back(1);
}
if (isSubsequence(guess))
{
ans.push_back(0);
++usedzeros;
}
else
{
ans.push_back(1);
++usedones;
}
}
else
{
for (int j = 0; j < usedones+1; ++j)
{
guess.push_back(1);
}
for (int j = 0; j < zeroct-usedzeros; ++j)
{
guess.push_back(0);
}
if (isSubsequence(guess))
{
ans.push_back(1);
++usedones;
}
else
{
ans.push_back(0);
++usedzeros;
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |