이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<iostream>
#include "combo.h"
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define mod 1000000007
#define inf 1e18
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define w(x) int x; cin>>x; while(x--)
string s="";
string sf;
string guess_sequence(int n){
s = (press("AB")?(press("A")?"A":"B"):(press("X")?"X":"Y"));
int ss = s.size();
if(n==1){
return s;
}
if(s=="A"){
for(int i=1;i<n-1;i++){
int c = press(s+"B"+s+"XB"+s+"XX"+s+"XY");
if(c==ss) s+="Y";
else if(c==ss+1) s+="B";
else s+="X";
ss=s.size();
}
sf = s+"B";
int q=press(sf);
if(q==n){
return sf;
}
sf=s+"X";
q=press(sf);
if(q==n){
return sf;
}
else{
return s+"Y";
}
}else if(s=="B"){
for(int i=1;i<n-1;i++){
int c = press(s+"A"+s+"XA"+s+"XX"+s+"XY");
if(c==ss) s+="Y";
else if(c==ss+1) s+="A";
else s+="X";
ss=s.size();
}
sf = s+"A";
int q=press(sf);
if(q==n){
return sf;
}
sf=s+"X";
q=press(sf);
if(q==n){
return sf;
}
else{
return s+"Y";
}
}else if(s=="X"){
for(int i=1;i<n-1;i++){
int c = press(s+"B"+s+"AB"+s+"AA"+s+"AY");
if(c==ss) s+="Y";
else if(c==ss+1) s+="B";
else s+="A";
ss=s.size();
}
sf = s+"A";
int q=press(sf);
if(q==n){
return sf;
}
sf=s+"B";
q=press(sf);
if(q==n){
return sf;
}
else{
return s+"Y";
}
}else if(s=="Y"){
for(int i=1;i<n-1;i++){
int c = press(s+"B"+s+"XB"+s+"XX"+s+"XA");
if(c==ss) s+="A";
else if(c==ss+1) s+="B";
else s+="X";
ss=s.size();
}
sf = s+"A";
int q=press(sf);
if(q==n){
return sf;
}
sf=s+"B";
q=press(sf);
if(q==n){
return sf;
}
else{
return s+"X";
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |