Submission #715476

#TimeUsernameProblemLanguageResultExecution timeMemory
715476lmqzzzThe Big Prize (IOI17_prize)C++14
0 / 100
104 ms208 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int lolipop = -1; int best = -1; int solve(int l, int r, int before_left) { if (l >= r) return -1; //[l, r) int m = l + r >> 1; // [l, m) [m + 1, r) int lm = m - 1, rm = m; int L, R; while (rm < r) { auto mid = ask(rm); if (mid[0] + mid[1] == 0) return rm; if (mid[0] + mid[1] == best) { L = mid[0], R = mid[1]; break; } rm++; } if (rm == r) { return solve(l, m, before_left); } else { return max(solve(l, m, before_left), solve(rm + 1, r, L)); } } int find_best(int n) { const int LIM = 500; vector<vector<int>> b(LIM); for (int i = 0; i < LIM; i++) { b[i] = ask(i); if (best < b[i][0] + b[i][1]) { best = b[i][0] + b[i][1]; lolipop = i; } if (b[i][0] + b[i][1] == 0) return i; } int cnt = 0; for (int i = 0; i < LIM; i++) { if (b[i][0] + b[i][1] < best) cnt++; } return solve(LIM, n, cnt); }

Compilation message (stderr)

prize.cpp: In function 'int solve(int, int, int)':
prize.cpp:10:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   10 |         int m = l + r >> 1;
      |                 ~~^~~
prize.cpp:12:13: warning: unused variable 'lm' [-Wunused-variable]
   12 |         int lm = m - 1, rm = m;
      |             ^~
prize.cpp:13:16: warning: variable 'R' set but not used [-Wunused-but-set-variable]
   13 |         int L, R;
      |                ^
prize.cpp:26:59: warning: 'L' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |                 return max(solve(l, m, before_left), solve(rm + 1, r, L));
      |                                                      ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...