이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define rep(i,a,b) for(int i=(a); i<(b); i++)
int n;
string s;
#define sz (int)s.size()
V<char> arr = {'A','B','X','Y'};
int f(char c){
int i = 0;
while(arr[i] != c) i++;
return i;
}
string guess_sequence(int _n){
n = _n;
// find first char
{
int ax = press("AX"), bx = press("BX");
if(ax && bx) s = "X";
else if(ax) s = "A";
else if(bx) s = "B";
else s = "Y";
}
// put s[0] as last char
swap(arr[f(s[0])], arr.back());
//cout << s << endl;
while(sz < n-1){
string t = "";
t += s; t += arr[0]; t += arr[0];
t += s; t += arr[0]; t += arr[1];
t += s; t += arr[0]; t += arr[2];
t += s; t += arr[1];
//cout << t << endl;
int len = press(t);
if(len==sz) s += arr[2];
else if(len==sz+1) s += arr[1];
else s += arr[0];
}
//assert(sz == n-1);
//cout << s << endl;
// last char
if(press(s+arr[0]+s+arr[1]) > sz){
if(press(s+arr[0]) > sz) s += arr[0];
else s += arr[1];
}
else s += arr[2];
//cout << s << endl;
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |