# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015903 | deera | 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;
int press(string p);
#include "combo.h"
string guess(int N) {
int a = press("AB");
int b = press("BX");
string f = "";
if (a == 1 && b == 1) {
f += "B";
}
if (a == 1 && b == 0) {
f += "A";
}
if (a == 0 && b == 1) {
f += "X";
}
if (a == 0 && b == 0) {
f += "Y";
}
if (f.size() == N) {
return f;
}
vector<string> r;
if (f != "A") r.push_back("A");
if (f != "B") r.push_back("B");
if (f != "X") r.push_back("X");
if (f != "Y") r.push_back("Y");
while (true) {
string g = f + r[0] + f + r[1] + r[0] + f + r[1] + r[1] + f + r[1] + r[2];
if (g.size() > N * 4) {
break;
} else {
int p = press(g);
if (p == f.size()) {
f += r[2];
} else if (p == f.size() + 1) {
f += r[0];
} else if (p == f.size() + 2) {
f += r[1];
}
}
}
// guessing the last character
int x = press(f + r[0] + f + r[1]) - f.size();
int y = press(f + r[0] + f + r[2]) - f.size();
if (x == 1 && y == 1) {
f += r[0];
}
if (x == 1 && y == 0) {
f += r[1];
}
if (x == 0 && y == 1) {
f += r[2];
}
if (x == 0 && y == 0) {
// shouldn't happen
}
return f;
}