Submission #316180

#TimeUsernameProblemLanguageResultExecution timeMemory
316180nikatamlianiThe Big Prize (IOI17_prize)C++14
20 / 100
75 ms384 KiB
#include <bits/stdc++.h> using namespace std; #include "prize.h" int find_best(int n) { int next = -1, at_most = min(500, n); vector < int > bad(2); for(int i = 0; i <= at_most; ++i) { vector < int > cur = ask(i); if(bad[0] + bad[1] < cur[0] + cur[1]) bad = cur; } for(int i = 0; i < n; i = next) { int l = i, r = n - 1; next = -1; vector < int > t = ask(i); if(t[0] + t[1] != bad[0] + bad[1]) { next = i + 1; if(t[0] == 0 && t[1] == 0) return i; continue; } while(r >= l) { int m = l + r >> 1; vector < int > x = ask(m); if(x == t) { next = m; l = m + 1; } else { r = m - 1; } } assert(next >= 0); vector < int > tt = ask(next); for(int j = next + 1; j < n; ++j) { vector < int > p = ask(j); if(p[0] + p[1] != bad[0] + bad[1]) { if(p[0] == 0 && p[1] == 0) return j; continue; } next = j; break; } } //this is bad for(int i = 0; i < n; ++i) { vector < int > p = ask(i); if(!p[0] && !p[1]) return i; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:20:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |             int m = l + r >> 1;
      |                     ~~^~~
prize.cpp:6:25: warning: control reaches end of non-void function [-Wreturn-type]
    6 |     vector < int > bad(2);
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...