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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
vector<char> chars {'A','B','X','Y'};
std::string guess_sequence(int N) {
srand(time(NULL));
string ans = "";
//find first character, 2 guess
char firstChar;
if (press(ans+chars[0]+chars[1]) > 0) {
if (press(ans+chars[0]) > 0) {
firstChar = chars[0];
}
else firstChar = chars[1];
}
else {
if (press(ans+chars[2]) > 0) {
firstChar = chars[2];
}
else firstChar = chars[3];
}
chars.erase(remove(chars.begin(),chars.end(),firstChar),chars.end());
ans += firstChar;
//each character, 1 guess
while (4*ans.size()+7 <= 4*N) { //while strategy works
int z = press(ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) - ans.size();
// cout << "guess: " << (ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) << " " << z;
if (z == 2) {
ans += chars[1];
}
else if (z == 1) {
ans += chars[0];
}
else {
ans += chars[2];
}
// cout << ",new: " << ans << "\n";
}
while (ans.size() < N) {
if (press(ans+chars[0])-ans.size() > 0) {
ans += chars[0];
}
else if (press(ans+chars[1])-ans.size() > 0) ans += chars[1];
else ans += chars[2];
}
// cout << ans << "\n";
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | while (4*ans.size()+7 <= 4*N) { //while strategy works
| ~~~~~~~~~~~~~~~^~~~~~
combo.cpp:58:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
58 | while (ans.size() < N) {
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |