# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007142 | christinelynn | 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"
string guess_sequence ( int n ){
string s = "";
string temp = "AB";
int y = press(temp);
if ( y == 1 || y == 2 ){
temp = "A";
y = press ( temp );
if ( y == 1 ) s = "A";
else s = "B";
}
else{
temp = "X";
y = press ( temp );
if ( y == 1 ) s = "X";
else s = "Y";
}
for ( int i = 1; i <= n - 2; i++ ){
string t1, t2, t3, t4;
if ( s[0] == 'A' ){
t1 = s; t1 += 'B';
t2 = s; t2 += "XX";
t3 = s; t3 += "XY";
t4 = s; t4 += "XB";
temp = t1 + t2 + t3 + t4;
y = press ( temp );
if ( y == s.length()) s += 'Y';
else if ( y == s.length() + 1) s += 'B';
else s += 'X';
}
else if ( s[0] == 'B'){
t1 = s; t1 += 'A';
t2 = s; t2 += "XX";
t3 = s; t3 += "XY";
t4 = s; t4 += "XA";
temp = t1 + t2 + t3 + t4;
y = press ( temp );
if ( y == s.length()) s += 'Y';
else if ( y == s.length() + 1) s += 'A';
else s += 'X';
}
else if ( s[0] == 'X'){
t1 = s; t1 += 'A';
t2 = s; t2 += "BB";
t3 = s; t3 += "BY";
t4 = s; t4 += "BA";
temp = t1 + t2 + t3 + t4;
y = press ( temp );
if ( y == s.length()) s += 'Y';
if ( y == s.length() + 1) s += 'A';
if ( y == s.length() + 2 ) s += 'B';
}
else if ( s[0] == 'Y' ){
t1 = s; t1 += 'B';
t2 = s; t2 += "XB";
t3 = s; t3 += "XA";
t4 = s; t4 += "XX";
temp = t1 + t2 + t3 + t4;
y = press ( temp );
if ( y == s.length() ) s += 'A';
if ( y == s.length() + 1) s += 'B';
if ( y == s.length() + 2 ) s += 'X';
}
}
if ( s[0] == 'A' ){
temp = "B";
y = press(temp);
if ( y == s.length() + 1) s += 'B';
else{
temp = "X";
y = press ( temp );
if ( y == s.length() + 1) s += 'X';
else s += 'Y';
}
}
else if ( s[0] == 'B' ){
temp = "A";
y = press ( temp );
if ( y == s.length() + 1) s += 'A';
else{
temp = "X";
y = press ( temp );
if ( y == s.length() + 1) s += 'X';
else s += 'Y';
}
}
else if ( s[0] == 'X' ){
temp = "A";
y = press ( temp );
if ( y == s.length() + 1) s += 'A';
else{
temp = "B";
y = press ( temp );
if ( y == s.length() + 1) s += 'B';
else s += 'Y';
}
}
else if ( s[0] == 'Y'){
temp = "A";
y = press ( temp );
if ( y == s.length() + 1) s += 'A';
else{
temp = "B";
y = press ( temp );
if ( y == s.length() + 1) s += 'B';
else s += 'X';
}
}
return s;
}