Submission #505991

#TimeUsernameProblemLanguageResultExecution timeMemory
505991LouayFarahCombo (IOI18_combo)C++14
30 / 100
102 ms604 KiB
#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 = ""; for(int i = 0; i<4; i++) { p.pb(choices[i]); if(press(p)==1) { s = p; break; } p = s; } while(int(s.length())<n) { for(int i = 0; i<4; i++) { if(choices[i]==s[0]) continue; if(choices[i]==s[int(s.length())-1]) continue; p = s; while(int(p.length())<4*n) { p.pb(choices[i]); } ll added = press(p) - int(s.length()); for(int j = 0; j<added; j++) s.pb(choices[i]); } } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...