# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
847998 | Charizard2021 | Hidden Sequence (info1cup18_hidden) | C++17 | 4 ms | 692 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){
vector<int> v1;
vector<int> v2;
int idx1 = 0;
int idx2 = 0;
while(true){
v1.push_back(0);
v2.push_back(1);
if(isSubsequence(v1)){
idx1++;
}
else{
idx2 = n - idx1;
break;
}
if(isSubsequence(v2)){
idx2++;
}
else{
idx1 = n - idx2;
break;
}
}
int val1 = idx1;
int val2 = idx2;
vector<int> ans(n, 0);
for(int i = 0; i < n; i++){
if(val1 == 0){
for(int j = i; j < n; j++){
ans[j] = 1;
}
break;
}
if(val2 == 0){
for(int j = i; j < n; j++){
ans[j] = 0;
}
break;
}
v1.clear();
v2.clear();
for(int j = 0; j < idx1 - val1 + 1; j++){
v1.push_back(0);
}
for(int j = 0; j < val2; j++){
v1.push_back(1);
}
for(int j = 0; j < idx2 - val2 + 1; j++){
v2.push_back(1);
}
for(int j = 0; j < val1; j++){
v2.push_back(0);
}
if(v1.size() <= (n / 2 + 1)){
if(isSubsequence(v1)){
ans[i] = 0;
val1--;
}
else{
ans[i] = 1;
val2--;
}
}
else{
if(isSubsequence(v2)){
ans[i] = 1;
val2--;
}
else{
ans[i] = 0;
val1--;
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |