This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
/*
string P = "AB";
int press(string S){
int maxi = 0;
for (int i = 0; i < S.size(); i++){
int j = i, k = 0, cnt = 0;
while (j < S.size() && k < P.size()){
if (S[j] != P[k]) break;
cnt++; j++; k++;
}
maxi = max(maxi, cnt);
}
cout << S << " " << maxi << '\n';
return maxi;
}
*/
string guess_sequence(int n){
string S = "";
int a = press("AB");
if (a >= 1){
int b = press("A");
if (b == 1){
S += "A";
}else{
S += "B";
}
}else{
int b = press("X");
if (b == 1) S += "X";
else S += "Y";
}
if (n == 1) return S;
string c = "ABXY";
string ch = "";
for (int i = 0; i < 4; i++){
if (c[i] == S[0]) continue;
ch += c[i];
}
for (int i = 1; i < n-1; i++){
string ask = S + ch[0] + ch[0] + S + ch[0] + ch[1] + S + ch[0] + ch[2] + S + ch[1];
int b = press(ask);
if (b == i) S += ch[2];
else if (b == i+1) S += ch[1];
else S += ch[0];
}
int b = press(S + ch[0]);
if (b == n) return S + ch[0];
int d = press(S + ch[1]);
if (d == n) return S + ch[1];
else return S + ch[2];
}
/*
int main(){
int n = P.size();
string s = guess_sequence(n);
cout << s << '\n';
if (s == P) cout << "YES\n";
else cout << "NO\n";
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |