# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471940 | nickmet2004 | Hidden Sequence (info1cup18_hidden) | C++11 | 0 ms | 0 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;
int Q;
int ask(int x , int y, int A){
vector<int> v;
while(x--) v.emplace_back(A);
while(y--) v.emplace_back(A^1);
int w = n0 - x;
while(w--) v.emplace_back(A);
return isSubsequence(v);
}
vector<int> find_Sequence(int n){
vector<int> ans;
ans.resize(n);
int n0 = n1 = 0;
for(int i = 1; i <= n; ++i){
if(!ask(i,0,0)){
n0 = i - 1;
n1 = n - n0;
break;
}
}
if(n0<n1) {Q^=1; swap(n0 , n1)};
while(1){
if(n==1)break;
int one= 1;
while(1){
if(!ask(n0 , one , Q)){
one--;
ans[n - one-1] = 1;
n -= one;
n0--;
break;
}
one++;
}
}
for(int i = 0; i < (int)ans.size(); ++i){
if(ans[i]) ans[i] = Q;
else ans[i] = Q^1;
}
return ans;
}