Submission #506020

#TimeUsernameProblemLanguageResultExecution timeMemory
506020LouayFarahCombo (IOI18_combo)C++14
0 / 100
1 ms200 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 = ""; vector<bool> visited(4, false); 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; break; } p = s; } while(int(s.length())<n) { vector<bool> used(4, false); while(true) { ll i = my_rand(0, 4); if(choices[i]==s[0]) { used[i] = true; continue; } if(used[i]) continue; ll cnt_not_used = 0; char c; for(int i = 0; i<4; i++) { if(!used[i]) { cnt_not_used++; c = choices[i]; } } if(cnt_not_used==1) { s.pb(c); break; } else { p.pb(choices[i]); if(press(p)==int(s.length())+1) { s.pb(choices[i]); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...