# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060319 | pera | Hidden Sequence (info1cup18_hidden) | C++17 | 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>
using namespace std;
int zero = 0 , one = 0;
bool isSubsequence(vector<int> x){
cout << "? ";
for(int y : x){
cout << y << " ";
}
cout << endl;
int X;
cin >> X;
return X;
}
vector<int> findSequence(int N){
vector<int> ans , X;
for(int i = 1;i <= N / 2 + 1;i ++){
X.emplace_back(1);
if(isSubsequence(X)){
one = i;
zero = N - i;
}
}
if(one == N / 2 + 1){
vector<int>().swap(X);
for(int i = 1;i <= N / 2 + 1;i ++){
X.emplace_back(0);
if(isSubsequence(X)){
zero = i;
one = N - i;
}
}
}
vector<int> o(2);
auto is_Zero = [&](){
vector<int> v;
if(o[0] + (one - o[1]) <= N / 2 + 1){
for(int x = 1;x <= o[0] + 1;x ++){
v.emplace_back(0);
}
for(int x = 1;x <= one - o[1];x ++){
v.emplace_back(1);
}
return isSubsequence(v);
}else{
for(int x = 1;x <= o[1] + 1;x ++){
v.emplace_back(1);
}
for(int x = 1;x <= zero - o[0];x ++){
v.emplace_back(0);
}
return !isSubsequence(v);
}
};
for(int i = 1;i <= N;i ++){
ans.emplace_back(!is_Zero());
o[ans.back()]++;
}
return ans;
}
int main(){
vector<int> t = findSequence(6);
for(int x : t){
cout << x << " ";
}
}