# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091359 | kotnid | Martian DNA (IOI16_dna) | C++14 | 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;
set<string>st;
bool make_test(strin p);
int T = 0;
// bool f(string s){
// string ans = "0";
// if(st.find(s) != st.end())return 0;
// cout << "? " << s << endl;
// T++;
// return (ans.find(s) != string::npos);
// }
bool f(string s){
if(st.find(s) != st.end())return 0;
// cout << "? " << s << endl;
return make_test(s);
// bool v;
// cin >> v;
// return v;
}
string analyse(int n, int t){
st.clear();
int len0 = 0;
string s = "0";
while(s.size() <= n && f(s)){
len0++;
s += "0";
}
st.insert(s);
s.pop_back();
if(len0 == 0){
string s2 = "";
for(int i=0; i<n; i++)s2 += "1";
return s2;
// cout << "! ";
// for(int i=0; i<n; i++)cout << 1;
// cout << endl;
// return ;
}
// right side
int flag = 1;
int cnt = 0;
while(1){
s += (char)(flag+'0');
cnt++;
if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
st.insert(s);
s.pop_back();
flag = 1-flag;
s += (char)(flag+'0');
cnt = 1;
if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
st.insert(s);
s.pop_back();
break;
}
flag = 1;
cnt = 0;
while(1){
s.insert(0, string(1,(char)(flag+'0')));
cnt++;
if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
st.insert(s);
s.erase(s.begin());
flag = 1-flag;
s.insert(0, string(1,(char)(flag+'0')));
cnt = 1;
if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
st.insert(s);
s.erase(s.begin());
break;
}
return s;
// cout << T << endl;
}
// int main(){
// int t;
// cin >> t;
// while(t--)solve();
// }