Submission #316261

#TimeUsernameProblemLanguageResultExecution timeMemory
316261nikatamlianiThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "prize.h" vector < vector < int > > memo; vector < int > memo_ask(int x) { if(!memo[x].empty()) return memo[x]; return memo[x] = ask(x); } int find_best(int n) { int next = -1, at_most = min(472, n - 1); vector < int > bad(2); memo.resize(n); for(int i = 0; i <= at_most; ++i) { if(bad[0] + bad[1] < memo_ask(i)[0] + memo_ask(i)[1]) { bad = cur; } if(cur[0] == 0 && cur[1] == 0) return i; } int good = 0; for(int i = 0; i <= at_most; ++i) { if(bad[0] + bad[1] != memo_ask(i)[0] + memo_ask(i)[1]) ++good; } const int BLOCK_SIZE = (n - at_most - 1) / (at_most + 1 - good) + 1; for(int i = at_most + 1; i < n; i = next + 1) { int l = i, r = n - 1; next = -1; vector < int > t = memo_ask(i); if(t[0] + t[1] != bad[0] + bad[1]) { next = i; if(t[0] == 0 && t[1] == 0) return i; continue; } int maybe = i + BLOCK_SIZE; if(maybe < n && memo_ask(maybe) == t) { next = maybe; continue; } if(maybe < n) r = maybe - 1; while(r >= l) { int m = l + r >> 1; vector < int > x = memo_ask(m); if(x == t) { next = m; l = m + 1; } else { r = m - 1; } } } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:15:19: error: 'cur' was not declared in this scope
   15 |             bad = cur;
      |                   ^~~
prize.cpp:17:12: error: 'cur' was not declared in this scope
   17 |         if(cur[0] == 0 && cur[1] == 0) return i;
      |            ^~~
prize.cpp:39:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |             int m = l + r >> 1;
      |                     ~~^~~
prize.cpp:11:25: warning: control reaches end of non-void function [-Wreturn-type]
   11 |     vector < int > bad(2);
      |                         ^