This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Be name khode //
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define all(x) x.begin(), x.end()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const int maxn5 = 5e5 + 10;
const int lg = 20;
string s[4];
char a[4];
std::string guess_sequence(int n) {
string c[4] = {"A", "B", "X", "Y"};
shuffle(c, c + 4, rng);
if(press(c[0]))
s[0] = s[1] = s[2] = s[3] = c[0];
else if(press(c[1]))
s[0] = s[1] = s[2] = s[3] = c[1];
else if(press(c[2]))
s[0] = s[1] = s[2] = s[3] = c[2];
else if(press(c[3]))
s[0] = s[1] = s[2] = s[3] = c[3];
for(int i = 0; i < 4; i++)
a[i] = c[i][0];
while(s[0].size() < n){
int keep = s[0].size();
for(int i = 0; i < 4; i++)
while(s[i].size() < n)
s[i].pb(a[rng() % 4]);
string t = s[0] + s[1] + s[2] + s[3];
int k = press(t);
for(int i = 0; i < 4; i++)
while(s[i].size() > k)
s[i].pop_back();
if(k == keep || rng() % 100 == 0){
int mx = 0, val = 0;
for(int i = 0; i < 4; i++){
int w = press(s[i]);
if(w >= val){
mx = i;
val = w;
}
}
for(int i = 0; i < 4; i++)
s[i] = s[mx];
}
}
shuffle(s, s + 4, rng);
for(int i = 0; i < 4; i++)
if(press(s[i]) == n)
return s[i];
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:39:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | while(s[0].size() < n){
| ~~~~~~~~~~~~^~~
combo.cpp:42:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | while(s[i].size() < n)
| ~~~~~~~~~~~~^~~
combo.cpp:47:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | while(s[i].size() > k)
| ~~~~~~~~~~~~^~~
combo.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |