# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
701033 | BobCompetitiveProgramming | Combo (IOI18_combo) | 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; using ll=long long;
int press(std::string p);
string getRandom(string start, string no, int sz){
while(start.size() < sz){
int r = rand() % 4 + 1;
if(r==1 && "A" != no) start += "A";
if(r==2 && "B" != no) start += "B";
if(r==3 && "X" != no) start += "X";
if(r==4 && "Y" != no) start += "Y";
}
return start;
}
string guess_sequence(int N){
string S = "", first;
vector<string> buttons{"A", "B", "X", "Y"};
for(auto& button : buttons)
if(button=="Y" || press(button)){
first = button, S += button;
break;
}
while(true){
if(S.size() == N)
return S;
for(auto& button : buttons) {
if(button == first)
continue;
if(button=="Y" || (first=="Y" && button=="X")) {
S += button;
break;
} else {
string ra = getRandom(button, first, min(S.size(), 4*N-S.size()));
int ret = press(S+ra);
if(ret>S.size()){
S += ra.substr(0, ret-S.size());
break;
}
}
}
}
}
int press(string s){
cout << " IN PRESS, ans with string s = " << s << endl;
ll ret; cin>>ret;
return ret;
}
int main(){
guess_sequence(5);
}