Submission #390472

#TimeUsernameProblemLanguageResultExecution timeMemory
390472KeshiThe Big Prize (IOI17_prize)C++17
90 / 100
126 ms1216 KiB
//In the name of God #include <bits/stdc++.h> #include "prize.h" using namespace std; typedef int ll; typedef pair<ll, ll> pll; const ll maxn = 2e5 + 100; const ll mod = 1e9 + 7; const ll inf = 1e9; #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() ll p[maxn], cnt; int find_best(int n){ srand(time(NULL)); for(ll i = 0; i < n; i++){ p[i] = i; } random_shuffle(p, p + n); ll x = 0; for(ll i = 0; i < min(480, n); i++){ auto f = ask(p[i]); cnt++; if(cnt == 10000) cout << 1 / 0; x = max(x, f[0] + f[1]); } ll ptr = 0; ll cnt3 = 0; while(ptr < n){ auto f = ask(ptr); if(f[0] + f[1] > x) cout << 1 / 0; cnt++; cnt3++; if(cnt3 > 480 * 2) return -1; if(cnt == 10000) cout << 1 / 0; if(f[0] + f[1] == 0) return ptr; if(f[0] + f[1] != x){ ptr++; continue; } ll l = ptr, r = n; ll cnt2 = 0; while(r - l > 1){ ll mid = (l + r) >> 1; auto f2 = ask(mid); cnt2++; cnt++; if(cnt == 10000) cout << 1 / 0; if(f2[0] == f[0] && f2[1] == f[1]) l = mid; else r = mid; } if(cnt2 > 18) return -1; ptr = r; } return 0; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:33:31: warning: division by zero [-Wdiv-by-zero]
   33 |    if(cnt == 10000) cout << 1 / 0;
      |                             ~~^~~
prize.cpp:40:38: warning: division by zero [-Wdiv-by-zero]
   40 |        if(f[0] + f[1] > x) cout << 1 / 0;
      |                                    ~~^~~
prize.cpp:44:31: warning: division by zero [-Wdiv-by-zero]
   44 |    if(cnt == 10000) cout << 1 / 0;
      |                             ~~^~~
prize.cpp:57:31: warning: division by zero [-Wdiv-by-zero]
   57 |    if(cnt == 10000) cout << 1 / 0;
      |                             ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...