이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char ch[] = {'A', 'B', 'X', 'Y'};
char findNextCharacter(string currentString) {
int f = 0, s = 1;
string query = currentString + ch[f] + currentString + ch[s];
int res = press(query);
if (res == sz(currentString))
f = 2, s = 3;
query = currentString + ch[f];
res = press(query);
return (res != sz(currentString) ? ch[f] : ch[s]);
}
string guess_sequence(int N) {
char first = findNextCharacter("");
string ans = "";
ans += first;
string buttons = "";
for (int i = 0; i < 4; ++i)
if (first != ch[i])
buttons += ch[i];
for (int i = 2; i < N; ++i) {
string query = "";
query = ans + buttons[1];
for (int j = 0; j < 3; ++j)
query += ans + buttons[2] + buttons[j];
int res = press(query);
if (res == i - 1)
ans += buttons[0];
else if (res == i)
ans += buttons[1];
else
ans += buttons[2];
}
if (N > 1) {
char last = findNextCharacter(ans);
ans += last;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |