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 all(aaa) aaa.begin(), aaa.end()
void guess_one_letter(string &s, string t) {
int l = -1, r = t.size() - 1;
while (r - l > 1) {
int p = (l + r) >> 1;
string g;
for (int i = 0; i <= p; i++) {
g += s + string(1, t[i]);
}
if (press(g) >= s.size() + 1)
r = p;
else
l = p;
}
s.push_back(t[r]);
}
string guess_sequence(int n) {
string s, t = "AXYB";
guess_one_letter(s, t);
t.erase(find(all(t), s[0]));
for (int i = 2; i < n; i++) {
string p = s + string(1, t[0])
+ s + string(1, t[1]) + string(1, t[0])
+ s + string(1, t[1]) + string(1, t[1])
+ s + string(1, t[1]) + string(1, t[2]);
int coins = press(p);
if (coins == i)
s.push_back(t[0]);
else if (coins == i + 1)
s.push_back(t[1]);
else
s.push_back(t[2]);
}
if (n > 1)
guess_one_letter(s, t);
return s;
}
Compilation message (stderr)
combo.cpp: In function 'void guess_one_letter(std::string&, std::string)':
combo.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | if (press(g) >= s.size() + 1)
| ~~~~~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |