이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
std::string p = "";
std::vector<char> vec = {'A','B','X','Y'};
char st;
int coin = press("AB");
if (coin == 1){
coin = press("A");
if (coin == 1){
st = 'A';
}
else{
st = 'B';
}
}
else if (coin != 2){
coin = press("X");
if (coin == 1){
st = 'X';
}
else{
st = 'Y';
}
}
if (coin == 2){
st = 'A';
}
auto it = find(vec.begin(),vec.end(),st);
vec.erase(it);
p.push_back(st);
if (coin == 2){
p.push_back('B');
}
for (int i = p.size(); i<N-1; i++){
string guess;
string one = p; one.push_back(vec[0]); one.push_back(vec[0]);
string two = p; two.push_back(vec[0]); two.push_back(vec[1]);
string three = p; three.push_back(vec[0]); three.push_back(vec[2]);
string four = p; four.push_back(vec[1]);
guess = one + two + three + four;
int res = press(guess);
char nxt;
if (res == i){
nxt = vec[2];
}
else if (res == i+1){
nxt = vec[1];
}
else{
nxt = vec[0];
}
p.push_back(nxt);
}
int sz = p.size();
if (sz == N){
return p;
}
char lst;
string guess;
string ek = p; ek.push_back(vec[0]);
string doo = p; doo.push_back(vec[1]);
guess = ek+doo;
int c = press(guess);
if (c == sz){
lst = vec[2];
}
else{
guess = p; guess.push_back(vec[0]);
c = press(guess);
if (c == sz){
lst = vec[1];
}
else{
lst = vec[0];
}
}
p.push_back(lst);
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |