# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141849 | Muhammet | Hidden Sequence (info1cup18_hidden) | C++20 | 1 ms | 408 KiB |
#include "bits/stdc++.h"
#include "grader.h"
// #include "grader.cpp"
using namespace std;
int n;
int f(int x){
vector <int> v;
for(int i = n/2+1; i > 0; i--){
v.clear();
for(int j = 0; j < i; j++){
v.push_back(x);
}
if(isSubsequence(v)){
return i;
}
}
return 0;
}
vector <int> findSequence (int N) {
n = N;
int a = f(0), b = n-a;
if(!a) b = f(1), a = n-b;
int x = 0, y = 1;
deque <int> d;
if(b > a) swap(a,b), swap(x,y);
vector <int> v, ans;
if(b == 0){
for(int i = 0; i < a; x++) v.push_back(x);
return v;
}
d.push_back(x);
for(int i = 0; i < b; i++) d.push_back(y);
int a1 = 0, b1 = 0;
while((int)ans.size() < n){
v.clear();
for(auto i : d) v.push_back(i);
if(isSubsequence(v)){
ans.push_back(x);
d.push_front(x);
a1++;
if(a1 == a){
while(b1 != b){
ans.push_back(y);
b1++;
}
break;
}
}
else {
ans.push_back(y);
d.pop_back();
b1++;
if(b1 == b){
while(a1 != a){
ans.push_back(x);
a1++;
}
break;
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |