이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string ans = "";
int val = press("AB");
if(val >= 1){
val = press("A");
if(val == 1){
ans += "A";
}else{
ans += "B";
}
}else{
val = press("X");
if(val >= 1){
ans += "X";
}else{
ans += "Y";
}
}
N--;
if(!N){
return ans;
}
if(ans == "A"){
int old = ans.length();
while(N-1){
val = press(ans+"BB"+ans+"BX"+ans+"BY"+ans+"X");
if((val-old) == 2){
ans += "B";
}else if((val-old)){
ans += "X";
}else{
ans += "Y";
}
old++;
N--;
}
val = press(ans+"B");
if(val == old+1){
ans += "B";
}else{
val = press(ans+"X");
if(val == old+1){
ans += "X";
}else{
ans += "Y";
}
}
}else if(ans == "B"){
int old = ans.length();
while(N-1){
val = press(ans+"AA"+ans+"AX"+ans+"AY"+ans+"X");
if((val-old) == 2){
ans += "A";
}else if((val-old)){
ans += "X";
}else{
ans += "Y";
}
old++;N--;
}
val = press(ans+"A");
if(val == old+1){
ans += "A";
}else{
val = press(ans+"X");
if(val == old+1){
ans += "X";
}else{
ans += "Y";
}
}
}else if(ans == "X"){
int old = ans.length();
while(N-1){
val = press(ans+"AA"+ans+"AB"+ans+"AY"+ans+"B");
if((val-old) == 2){
ans += "A";
}else if((val-old)){
ans += "B";
}else{
ans += "Y";
}
old++;N--;
}
val = press(ans+"B");
if(val == old+1){
ans += "B";
}else{
val = press(ans+"A");
if(val == old+1){
ans += "A";
}else{
ans += "Y";
}
}
}else{
int old = ans.length();
while(N-1){
val = press(ans+"AA"+ans+"AB"+ans+"AX"+ans+"B");
if((val-old) == 2){
ans += "A";
}else if((val-old)){
ans += "B";
}else{
ans += "X";
}
old++;N--;
}
val = press(ans+"B");
if(val == old+1){
ans += "B";
}else{
val = press(ans+"X");
if(val == old+1){
ans += "X";
}else{
ans += "A";
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |