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 "combo.h"
#include<bits/stdc++.h>
using namespace std;
string find_single(int n, string mom){
int l=mom.size();
string ask = "";
string ans = "";
ask = mom + "A" + mom + "B";
int coins = press(ask);
if(0 < coins-l){
ask= mom + "A";
coins = press(ask);
if(0 < coins-l){
ans = "A";
}
else{
ans = "B";
}
}
else{
ask = mom + "X";
coins = press(ask);
if(0 < coins-l){
ans = "X";
}
else{
ans = "Y";
}
}
return ans;
}
string guess_sequence(int n) {
string ans="";
ans = find_single(n, ans);
set<string> opt = {"A", "B", "X", "Y"};
opt.erase(ans);
string a = *opt.begin();
string b = *next(opt.begin());
string c = *next(next(opt.begin()));
for(int i=1; i<n-1; i++){
string ask = ans +a +a;
ask += ans + a +b;
ask += ans + a +c;
ask += ans + b;
int coins=press(ask);
if(coins == i+2){
ans += a;
}
else if(coins == i+1){
ans += b;
}
else{
ans += c;
}
}
if(1<n){
ans += find_single(n, ans);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |