# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96498 | dnass | Hidden Sequence (info1cup18_hidden) | C++14 | 9 ms | 404 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 <cstdio>
#include <vector>
#include <ctime>
#include <cstdlib>
#include "grader.h"
using namespace std;
int n;
int halfp;
int ones = -1, zeros = -1;
int onesones, zeroszeros;
vector<int> findSequence (int N){
n = N;
halfp = (n/2)+1;
vector<int> half_ones;
for(int i=1;i<=halfp;i++){
half_ones.push_back(1);
if(!isSubsequence(half_ones)){
ones = i-1;
break;
}
}
if(ones!=-1){
zeros = n-ones;
}else{
vector<int> half_zeros;
for(int i=1;i<=halfp;i++){
half_zeros.push_back(0);
if(!isSubsequence(half_zeros)){
zeros = i-1;
break;
}
}
ones = n-zeros;
}
onesones = ones;
zeroszeros = zeros;
vector<int> ans;
if(ones==n){
for(int i=0;i<n;i++) ans.push_back(1);
}else if(zeros==n){
for(int i=0;i<n;i++) ans.push_back(0);
}else{
while(onesones>0&&zeroszeros>0){
//printf("o:%d z:%d\n", onesones, zeroszeros);
vector<int> subs0;
for(int i=0;i<zeros-zeroszeros+1;i++) subs0.push_back(0);
for(int i=0;i<onesones;i++) subs0.push_back(1);
vector<int> subs1;
for(int i=0;i<ones-onesones+1;i++) subs1.push_back(1);
for(int i=0;i<zeroszeros;i++) subs1.push_back(0);
if((int)subs0.size()<=halfp){
if(isSubsequence(subs0)){
ans.push_back(0);
zeroszeros--;
}else{
ans.push_back(1);
onesones--;
}
}else{
if(isSubsequence(subs1)){
ans.push_back(1);
onesones--;
}else{
ans.push_back(0);
zeroszeros--;
}
}
}
if(onesones==0){
for(int i=0;i<zeroszeros;i++) ans.push_back(0);
}else if(zeroszeros==0){
for(int i=0;i<onesones;i++) ans.push_back(1);
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |