# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280413 | amalla | 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 "combo.h"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
if (press("A")) {
string M = "BXY", S = "A", control;
if (N==1) return S;
for (int i = 0; i<N-1; ++i) {
control = S+M[0]+M[0];
control += S+M[0]+M[1];
control += S+M[0]+M[2];
control += S+M[1];
int coins = press(control);
if (coins==S.size()) S+=M[2];
else if (coins==S.size()+1) S+=M[1];
else S+=M[0];
}
}
else if (press("B")) {
string M = "AXY", S = "B", control;
if (N==1) return S;
for (int i = 0; i<N-1; ++i) {
control = S+M[0]+M[0];
control += S+M[0]+M[1];
control += S+M[0]+M[2];
control += S+M[1];
int coins = press(control);
if (coins==S.size()) S+=M[2];
else if (coins==S.size()+1) S+=M[1];
else S+=M[0];
}
}
else if (press("X")) {
string M = "ABY", S = "X", control;
if (N==1) return S;
for (int i = 0; i<N-1; ++i) {
control = S+M[0]+M[0];
control += S+M[0]+M[1];
control += S+M[0]+M[2];
control += S+M[1];
int coins = press(control);
if (coins==S.size()) S+=M[2];
else if (coins==S.size()+1) S+=M[1];
else S+=M[0];
}
}
else {
string M = "ABX", S = "Y", control;
if (N==1) return S;
for (int i = 0; i<N-1; ++i) {
control = S+M[0]+M[0];
control += S+M[0]+M[1];
control += S+M[0]+M[2];
control += S+M[1];
int coins = press(control);
if (coins==S.size()) S+=M[2];
else if (coins==S.size()+1) S+=M[1];
else S+=M[0];
}
}
return S;
}