#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll my_coins = 10000;
bool myPrevDecision;
ll myPrevBet = 0;
void fresh_run_user_init()
{
my_coins = 10000;
myPrevBet = 0;
}
// baseline implementation, scores ~ 10k.
pair<ll,bool> make_bet(bool previousSpinResult)
{
my_coins = (my_coins + ((previousSpinResult == myPrevDecision)?myPrevBet:-myPrevBet));
myPrevDecision = rand()%2;
if(my_coins >= 100)
{
myPrevBet = 100;
return {100, myPrevDecision};
}
else
{
myPrevBet = 0;
return {0,myPrevDecision};
}
}
//tester's code
int spinRoulette()
{
return rand()%2;
}
int main(){
srand(time(0));
int RUNS = 10000;
ll avg_score = 0;
//Can u design a strategy such that avg_score/score overflows?
for(int ith_run = 0; ith_run < RUNS; ith_run++)
{
fresh_run_user_init();
ll user_coins = 10000;
int spins_left = 5000;
// spin result, 0 means even and 1 means odd.
bool result = spinRoulette();
while(spins_left--)
{
pair<ll,bool> user_bet = make_bet(result);
//You cannot make a bet larger than the money you have.
assert(user_bet.first <= user_coins);
//spin the roulette.
result = spinRoulette();
//lost/won
if(result == user_bet.second)
user_coins += user_bet.first;
else user_coins -= user_bet.first;
}
avg_score += user_coins;
}
cout << "YOUR BOT SCORED : "<<(1.0*avg_score)/RUNS;
return 0;
}
//End
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBmcihhLGIpIGZvcihpbnQgaSA9IGE7IGkgPCBiOyBpKyspCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKI2RlZmluZSB0cmlwbGV0IHBhaXI8aW50LHBhaXI8aW50LGludD4+CiNkZWZpbmUgZmFzdF9pbyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKE5VTEwpCnVzaW5nIG5hbWVzcG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