이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <iostream>
#include <cassert>
#include <algorithm>
#include "combo.h"
std::string get_first_char()
{
std::vector<std::string> available_chars = {"A", "B", "X", "Y"};
for (int i = 0; i < 4; i++) {
if (press(available_chars[i]) == 1) {
return available_chars[i];
}
}
assert(false);
return "-";
}
std::string guess_sequence(int N) {
std::vector<std::string> available_chars = {"A", "B", "X", "Y"};
std::string first_char = get_first_char();
available_chars.erase(find(available_chars.begin(), available_chars.end(), first_char));
// std::cout << "Available characters: ";
// for (auto c : available_chars) {
// std::cout << c << " ";
// }
// std::cout << '\n';
assert(available_chars.size() == 3);
std::string ans = first_char;
for (int i = 1; i < N - 1; i++) {
std::string next = "";
next += ans + available_chars[0];
next += ans + available_chars[1] + available_chars[0];
next += ans + available_chars[1] + available_chars[1];
next += ans + available_chars[1] + available_chars[2];
int coins = press(next) - i;
assert(coins >= 0 && coins <= 2);
if (coins == 0) {
ans += available_chars[2];
}
else if (coins == 1) {
ans += available_chars[0];
}
else {
ans += available_chars[1];
}
}
if ((int)ans.size() == N) {
return ans;
}
int final_coins1 = press(ans + available_chars[0]);
int final_coins2 = press(ans + available_chars[1]);
if (final_coins1 == N) {
ans += available_chars[0];
}
else if (final_coins2 == N) {
ans += available_chars[1];
}
else {
ans += available_chars[2];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |