# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
786547 | JoenPoenMan | Combo (IOI18_combo) | 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 "grader.cpp"
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
vector<char> chars = {'X', 'Y', 'A', 'B'};
string Sol;
std::string guess_sequence(int N) {
if (press("AB") >= 1) Sol = (press("A") ? "A" : "B");
else Sol = (press("X") ? "X" : "Y");
chars.erase(find(chars.begin(), chars.end(), Sol[0]));
for (int i = 1; i < N-1; i++) {
string inp;
inp += Sol + chars[0];
inp += Sol + chars[1] + chars[0];
inp += Sol + chars[1] + chars[1];
inp += Sol + chars[1] + chars[2];
int res = press(inp);
if (res == Sol.length()) Sol.push_back(chars[2]);
else if (res == Sol.length()+1) Sol.push_back(chars[0]);
else Sol.push_back(chars[1]);
}
string inp;
inp = Sol + chars[0] + Sol + chars[1];
if (press(inp) == Sol.length()) Sol.push_back(chars[2]);
else {
inp = Sol + chars[0];
if (press(inp) == Sol.length()) Sol.push_back(chars[1]);
else Sol.push_back(chars[0]);
}
return Sol;
}