# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1104619 | anmattroi | Combo (IOI18_combo) | C++14 | 30 ms | 1644 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>
#include "combo.h"
using namespace std;
//ABXY
string guess_sequence(int N) {
string p = "";
int p1 = press("AB"), p2;
switch (p1) {
case 2:
p = "AB";
break;
case 1 :
p2 = press("A");
if (p2 == 0) p = "B";
else p = "A";
break;
case 0 :
p2 = press("X");
if (p2 == 0) p = "Y";
else p = "X";
break;
}
while (p.size() < N-1) {
string T;
switch (p[0]) {
case 'A' :
T = p + "BB" + p + "BX" + p + "BY" + p + "X";
p1 = press(T) - p.size();
if (p1 == 2) p.push_back('B');
else if (p1 == 1) p.push_back('X');
else p.push_back('Y');
break;
case 'B' :
T = p + "AA" + p + "AX" + p + "AY" + p + "X";
p1 = press(T) - p.size();
if (p1 == 2) p.push_back('A');
else if (p1 == 1) p.push_back('X');
else p.push_back('Y');
break;
case 'X' :
T = p + "AA" + p + "AB" + p + "AY" + p + "B";
p1 = press(T) - p.size();
if (p1 == 2) p.push_back('A');
else if (p1 == 1) p.push_back('B');
else p.push_back('Y');
break;
case 'Y' :
T = p + "AA" + p + "AB" + p + "AX" + p + "B";
p1 = press(T) - p.size();
if (p1 == 2) p.push_back('A');
else if (p1 == 1) p.push_back('B');
else p.push_back('X');
}
}
if (p.size() == N) return p;
switch (p[0]) {
case 'A' :
p1 = press(p + "B" + p + "X") - p.size();
if (p1 == 1) {
p2 = press(p + "B") - p.size();
if (p2 == 1) p.push_back('B');
else p.push_back('X');
} else p.push_back('Y');
break;
case 'B' :
p1 = press(p + "A" + p + "X") - p.size();
if (p1 == 1) {
p2 = press(p + "A") - p.size();
if (p2 == 1) p.push_back('A');
else p.push_back('X');
} else p.push_back('Y');
break;
case 'X' :
p1 = press(p + "A" + p + "B") - p.size();
if (p1 == 1) {
p2 = press(p + "A") - p.size();
if (p2 == 1) p.push_back('A');
else p.push_back('B');
} else p.push_back('Y');
break;
case 'Y' :
p1 = press(p + "A" + p + "B") - p.size();
if (p1 == 1) {
p2 = press(p + "A") - p.size();
if (p2 == 1) p.push_back('A');
else p.push_back('B');
} else p.push_back('X');
break;
}
return p;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |