# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973493 | shoryu386 | Hidden Sequence (info1cup18_hidden) | C++17 | 5 ms | 948 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;
vector < int > findSequence (int N){
int A = 1, B = 0;
vector<int> test;
int numA = 0;
for (int x = 1; x <= N/2+1; x++){
test.push_back(A);
if (isSubsequence(test)){
numA++;
}
else break;
}
if (numA >= N/2+1){
swap(A, B);
numA = 0;
test.clear();
for (int x = 1; x <= N/2+1; x++){
test.push_back(A);
if (isSubsequence(test)){
numA++;
}
else break;
}
}
int filler[numA+1]; memset(filler, 0, sizeof(filler));
test.clear();
int cap = N/4;
int marker = -1;
for (int x = 0; x <= numA; x++){
while (true){
filler[x]++;
test.clear();
if (filler[x] > cap){
filler[x] = 0;
marker = x;
break;
}
for (int y = 0; y < x; y++){
test.push_back(A);
}
for (int y = 0; y < filler[x]; y++){
test.push_back(B);
}
for (int y = 0; y < numA - x; y++){
test.push_back(A);
}
if (test.size() <= N && isSubsequence(test)){
continue;
}
else {filler[x]--; break;}
}
}
int numB = N-numA;
if (marker != -1){
int cursum = 0;
for (int x = 0; x <= numA; x++){
cursum += filler[x];
}
filler[marker] = numB - cursum;
}
test.clear();
for (int y = 0; y < numA; y++){
for (int z = 0; z < filler[y]; z++){
test.push_back(B);
}
test.push_back(A);
}
for (int z = 0; z < filler[numA]; z++){
test.push_back(B);
}
return test;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |