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"
using namespace std;
#define endl "\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const long long MOD = 1e9+7;
const long long INF = 1e18;
int nx[4] = {0, 0, -1, 1};
int ny[4] = {1, -1, 0, 0};
ll my_rand(ll l, ll r)
{
srand(chrono::steady_clock::now().time_since_epoch().count());
ll len = r-l;
ll a = rand()%len;
ll b = rand()%len;
ll res = ((((a%len)*((RAND_MAX+1)%len))%len) + (b%len))%len;
if(res<l)
res +=l;
return res;
}
int press(string p);
string guess_sequence(int n)
{
string s = "";
string choices = "ABXY";
string p = "";
vector<bool> visited(4, false);
ll restricted = 0;
while(true)
{
ll x = my_rand(0, 4);
if(visited[x])
continue;
visited[x] = true;
p.pb(choices[x]);
if(press(p)==1)
{
s = p;
restricted = x;
break;
}
p = s;
}
while(int(s.length())<n)
{
vector<bool> used(4, false);
used[restricted] = true;
used[int(s.length())-1] = true;
p = s;
while(true)
{
p = s;
ll x = my_rand(0, 4);
if(used[x])
continue;
used[x] = true;
while(int(p.length())<4*n)
{
p.pb(choices[x]);
}
ll added = press(p)-int(s.length());
if(added>0)
{
for(int k = 0; k<added; k++)
s.pb(choices[x]);
break;
}
}
}
return s;
}
Compilation message (stderr)
combo.cpp: In function 'long long int my_rand(long long int, long long int)':
combo.cpp:26:35: warning: integer overflow in expression of type 'int' results in '-2147483648' [-Woverflow]
26 | ll res = ((((a%len)*((RAND_MAX+1)%len))%len) + (b%len))%len;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |