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;
typedef string str;
str guess_sequence(int n){
// std::string p = "";
// for (int i = 0; i < 4 * N; ++i) {
// p += 'A';
// }
// int coins = press(p);
// std::string S = "";
// for (int i = 0; i < N; ++i) {
// S += 'A';
// }
// return S;
str al = "ABXY";
if( press(al.substr(0, 2)) == 0) swap(al[0], al[2]), swap(al[1], al[3]);
if( press(al.substr(0, 1)) == 0) swap(al[0], al[1]);
// for(int i = 1; i < 4; i++){
// if( press( al.substr(i, 1) ) ){
// swap(al[i], al[0]);
// break;
// }
// }
str ans = "";
ans += al[0];
if(n == 1)
return ans;
for(int i = 1; i < n - 1; i++){
str q = "";
q += ans + al[1];
q += ans + al[2] + al[1];
q += ans + al[2] + al[2];
q += ans + al[2] + al[3];
int res = press(q);
if(res == i) ans += al[3];
if(res == i + 1) ans += al[1];
if(res == i + 2) ans += al[2];
}
for(int i = 2; i < 4; i++){
if( press( ans + al[i] ) == n ){
return ans + al[i];
}
}
return ans + al[1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |