# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766928 | turtlemode | 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 "combo.h"
#include <set>
#include <list>
#include <iostream>
using namespace std;
std::string guess_sequence(int N) {
if (N == 0){
return "";
}
std::string S = "";
if (press("AB")){
if (press("A")){
S += "A";
}
else{
S += "B";
}
} else {
if (press("X")){
S += "X";
}
else{
S += "Y";
}
}
if (N == 1){
return S;
}
set<string> all_chars {"A", "B", "X", "Y"};
all_chars.erase(S);
vector<string> legal_chars;
set<string>::iterator k;
for (k = all_chars.begin(); k != all_chars.end(); ++k)
legal_chars.push_back(*k);
//cout << "Current: " << S << endl;
while (S.length() < N - 1){
// int coins = press(S + "B" + S + "XB" + S + "XX" + S + "XY");
int coins = press(S + legal_chars[0] + S + legal_chars[1] + legal_chars[0] + S + legal_chars[1] + legal_chars[1] + S + legal_chars[1] + legal_chars[2]);
if (coins == S.length() + 1){
S += legal_chars[0];
}
else if (coins == S.length() + 2){
S += legal_chars[1];
}
else if (coins == S.length() + 0){
S += legal_chars[2];
}
else {
//cout << "Wuut" << endl;
}
//cout << "Current: " << S << endl;
}
if (press(S + legal_chars[0]) == S.length() + 1){
return S + legal_chars[0];
}
if (press(S + legal_chars[1]) == S.length() + 1){
return S + legal_chars[1];
}
else{
return S + legal_chars[2];
}
//cout << "Wuuut2" << endl;
return S;
}