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 combination;
int press(string s) {
int n = (int) combination.length(), m = (int) s.length(), ans = 0;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < n; j++) {
if (i + j >= m || s[i + j] != combination[j]) {
break;
}
cnt++;
}
ans = max(ans, cnt);
}
return ans;
}*/
string guess_sequence(int N) {
if (N == 1) {
if (press("A") == 1) {
return "A";
} else {
if (press("B") == 1) {
return "B";
} else {
if (press("X") == 1) {
return "X";
} else {
return "Y";
}
}
}
}
string ans = "";
if (press("AB") > 0) {
if (press("A") > 0) {
ans = "A";
} else {
ans = "B";
}
} else {
if(press("X") > 0) {
ans = "X";
} else {
ans = "Y";
}
}
if (N == 1) {
return ans;
}
for (int i = 1; i < N - 1; i++) {
int k = ans.length();
if (ans[0] == 'A') {
int x = press(ans + "B" + ans + "XB" + ans + "XX" + ans + "XY");
//cout << x << endl;
if (x == k) {
ans += 'Y';
} else {
if (x == k + 1) {
ans += 'B';
} else {
ans += 'X';
}
}
} else {
if (ans[0] == 'B') {
int x = press(ans + "A" + ans + "XA" + ans + "XX" + ans + "XY");
//cout << x << endl;
if (x == k) {
ans += 'Y';
} else {
if (x == k + 1) {
ans += 'A';
} else {
ans += 'X';
}
}
} else {
if (ans[0] == 'X') {
int x = press(ans + "A" + ans + "BA" + ans + "BB" + ans + "BY");
//cout << x << endl;
if (x == k) {
ans += 'Y';
} else {
if (x == k + 1) {
ans += 'A';
} else {
ans += 'B';
}
}
} else {
int x = press(ans + "A" + ans + "BA" + ans + "BB" + ans + "BX");
//cout << x << endl;
if (x == k) {
ans += 'X';
} else {
if (x == k + 1) {
ans += 'A';
} else {
ans += 'B';
}
}
}
}
}
}
int k = ans.length();
if (ans[0] == 'A') {
if (press(ans + 'B') == k + 1) {
ans += 'B';
} else {
if (press(ans + 'X') == k + 1) {
ans += 'X';
} else {
ans += 'Y';
}
}
} else {
if (ans[0] == 'B') {
if (press(ans + 'A') == k + 1) {
ans += 'A';
} else {
if (press(ans + 'X') == k + 1) {
ans += 'X';
} else {
ans += 'Y';
}
}
} else {
if (ans[0] == 'X') {
if (press(ans + 'A') == k + 1) {
ans += 'A';
} else {
if (press(ans + 'B') == k + 1) {
ans += 'B';
} else {
ans += 'Y';
}
}
} else {
if (press(ans + 'A') == k + 1) {
ans += 'A';
} else {
if (press(ans + 'B') == k + 1) {
ans += 'B';
} else {
ans += 'X';
}
}
}
}
}
return ans;
}
/*int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> combination;
cout << guess_sequence(combination.length()) << '\n';
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |