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 <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>
#include "combo.h"
using namespace std;
using ll = long long;
//int press(string s) {
// return 0;
//}
string guess_sequence(int N) {
string cur;
string letters[] {"A", "B", "X", "Y"};
// find first letter
string first;
if (press(letters[0] + letters[1]) > 0) {
if (press(letters[0]) == 1) {
first = letters[0];
} else {
first = letters[1];
}
} else {
if (press(letters[2]) == 1) {
first = letters[2];
} else {
first = letters[3];
}
}
cur += first;
if (N == 1)
return cur;
// array without first
string n_letters[3]; int nxt = 0;
for (string c : letters) {
if (c != first)
n_letters[nxt++] = c;
}
// find next letters
for (int i = 1; i < N - 1; i++) {
int p_len = press(cur + n_letters[0] + n_letters[0]
+ cur + n_letters[0] + n_letters[1]
+ cur + n_letters[0] + n_letters[2]
+ cur + n_letters[1]);
if (p_len == i)
cur += n_letters[2];
else if (p_len == i + 1)
cur += n_letters[1];
else
cur += n_letters[0];
}
if (press(cur + n_letters[0]) == N) {
cur += n_letters[0];
} else if (press(cur + n_letters[1]) == N) {
cur += n_letters[1];
} else {
cur += n_letters[2];
}
return cur;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |