이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <combo.h>
using namespace std;
/*string S="ABX";
int press(string p){
cout<<p<<" ";
int len = p.length();
int coins = 0;
for (int i = 0, j = 0; i < len; ++i) {
if (j < S.size() && S[j] == p[i]) {
++j;
} else if (S[0] == p[i]) {
j = 1;
} else {
j = 0;
}
coins = max(coins, j);
}
return coins;
}*/
string guess_sequence(int N){
string result;
int guessresult;
guessresult = press("AB");
if(guessresult){
guessresult = press("A");
if(guessresult)
result = "A";
else
result = "B";
}
else{
guessresult = press("X");
if(guessresult)
result = "X";
else
result = "Y";
}
if(N==1)
return result;
if(result[0]=='A')
for(int i=0;i<N-2;i++){
guessresult = press(result + "B" + result + "XB" + result + "XX" + result + "XY");
if(guessresult == (int)result.size()+1){
result.push_back('B');
}
else if(guessresult == (int)result.size()){
result.push_back('Y');
}
else{
result.push_back('X');
}
}
if(result[0]=='B')
for(int i=0;i<N-2;i++){
guessresult = press(result + "A" + result + "XA" + result + "XX" + result + "XY");
if(guessresult == (int)result.size()+1){
result.push_back('A');
}
else if(guessresult == (int)result.size()){
result.push_back('Y');
}
else{
result.push_back('X');
}
}
else if(result[0]=='X')
for(int i=0;i<N-2;i++){
guessresult = press(result + "B" + result + "AB" + result + "AA" + result + "AY");
if(guessresult == (int)result.size()+1){
result.push_back('B');
}
else if(guessresult == (int)result.size()){
result.push_back('Y');
}
else{
result.push_back('A');
}
}
else if(result[0]=='Y')
for(int i=0;i<N-2;i++){
guessresult = press(result + "B" + result + "XB" + result + "XX" + result + "XA");
if(guessresult == (int)result.size()+1){
result.push_back('B');
}
else if(guessresult == (int)result.size()){
result.push_back('A');
}
else{
result.push_back('X');
}
}
if(result[0] == 'X'){
guessresult = press(result+"A"+result+"B");
if(guessresult == N){
guessresult = press(result+"A");
if(guessresult == N)
result.push_back('A');
else
result.push_back('B');
}
else{
result.push_back('Y');
}}
if(result[0] == 'Y'){
guessresult = press(result+"A"+result+"B");
if(guessresult == N){
guessresult = press(result+"A");
if(guessresult == N)
result.push_back('A');
else
result.push_back('B');
}
else{
result.push_back('X');
}}
if(result[0] == 'A'){
guessresult = press(result+"X"+result+"B");
if(guessresult == N){
guessresult = press(result+"X");
if(guessresult == N)
result.push_back('X');
else
result.push_back('B');
}
else{
result.push_back('Y');
}}
if(result[0] == 'B'){
guessresult = press(result+"A"+result+"X");
if(guessresult == N){
guessresult = press(result+"A");
if(guessresult == N)
result.push_back('A');
else
result.push_back('X');
}
else{
result.push_back('Y');
}}
return result;
}
/*int main(){
cout<<guess_sequence(3);
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |