이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
char firstLetter='X';
if(press("X")) firstLetter = 'X';
else if(press("Y")) firstLetter = 'Y';
else if(press("A")) firstLetter = 'A';
else if(press("B")) firstLetter = 'B';
string wyn = "";
wyn.push_back(firstLetter);
for(int i = 1; i < N-1; i++){
if(firstLetter=='A'){
int tmp = press(wyn+"X"+wyn+"YX"+wyn+"YB"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('B');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('X');
}else wyn.push_back('Y');
}
if(firstLetter=='B'){
int tmp = press(wyn+"X"+wyn+"YX"+wyn+"YA"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('X');
}else wyn.push_back('Y');
}
if(firstLetter=='X'){
int tmp = press(wyn+"B"+wyn+"YB"+wyn+"YA"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('B');
}else wyn.push_back('Y');
}
if(firstLetter=='Y'){
int tmp = press(wyn+"B"+wyn+"XB"+wyn+"XA"+wyn+"XX");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('B');
}else wyn.push_back('X');
}
}
char lastLetter;
if(firstLetter!='X'&&press(wyn+"X")==N) lastLetter = 'X';
else if(firstLetter!='Y'&&press(wyn+"Y")==N) lastLetter = 'Y';
else if(firstLetter!='A'&&press(wyn+"A")==N) lastLetter = 'A';
else if(firstLetter!='B'&&press(wyn+"B")==N) lastLetter = 'B';
wyn.push_back(lastLetter);
return wyn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |