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;
#define ll long long
#define vi vector<int>
#define pb push_back
#define coord pair<int, int>
const int MOD = 1e9 + 7;
const int MAXN = 1e3;
// int dp[MAXN];
string guess_sequence(int N) {
// find first letter in 2 presses
int res;
res = press("AB");
string f;
if (res >= 1) {
res = press("A");
if (res == 1) {
f = "A";
} else {
f = "B";
}
} else {
res = press("X");
if (res == 1) {
f = "X";
} else {
f = "Y";
}
}
if (N==1) {
return f;
}
vector<string> chars = {"A", "B", "X", "Y"};
chars.erase(find(chars.begin(), chars.end(), f));
// cout << "left letters:" << endl;
// for (string c : chars) {
// cout << c << endl;
// }
// cout << endl;
string ans = f;
for (int i=1; i<N-1; i++) {
// chars has length 3
// excluding last character from chars
string g = ans + chars[0];
g += ans + chars[1] + chars[0];
g += ans + chars[1] + chars[1];
g += ans + chars[1] + chars[2];
res = press(g);
if (res == (int)ans.length()) {
ans += chars[2];
} else if (res == (int)ans.length()+1) {
ans += chars[0];
} else {
ans += chars[1];
}
}
// guess last letter
res = press(ans + chars[0] + ans + chars[1]);
if (res == N) {
res = press(ans + chars[0]);
if (res == N) {
ans += chars[0];
} else {
ans += chars[1];
}
} else {
ans += chars[2];
}
cout << "My answer: " << ans << endl;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |