Submission #1296619

#TimeUsernameProblemLanguageResultExecution timeMemory
1296619NamnamseoThe Big Prize (IOI17_prize)C++20
Compilation error
0 ms0 KiB
#include "prize.h" #include <utility> using namespace std; using pp=pair<int,int>; const int maxn = int(2e5) + 10; pp cache[maxn]; bool vis[maxn]; pp Ask(int i) { if (vis[i]) return cache[i]; vis[i] = true; vector<int> res = ask(i); if (res[0]+res[1] == 0) throw i; return cache[i] = {res[0], res[1]}; } int lowest_rank; int _get_lowest_rank(int n) { int mx = 0, step=n/500; for (int i=0; i<500; ++i) { auto [a, b] = Ask(i*step); mx = max(mx, a+b); } return mx; } bool is_trash(int i) { auto [ca, cb] = Ask(i); return ca+cb == lowest_rank; } bool weirdo[maxn]; void find_all_weirdos(int l, int r, int cnt, int bl, int br) { for (;;) { if (!cnt || l>r) return; if (cache[l]) { if (!is_trash(l)) { weirdo[l] = true; --cnt; ++bl; } ++l; continue; } if (cache[r]) { if (!is_trash(r)) { weirdo[r] = true; --cnt; ++br; } --r; continue; } break; } int md = (l+r)/2; for (int i=md; l<=i; --i) { auto [ca, cb] = Ask(i); if (ca+cb == lowest_rank) { find_all_weirdos(l, i-1, ca-bl, bl, lowest_rank-ca); break; } else { weirdo[i] = true; } } for (int i=md; i<=r; ++i) { auto [ca, cb] = Ask(i); if (ca+cb == lowest_rank) { find_all_weirdos(i+1, r, cb-br, lowest_rank-cb, br); break; } else { weirdo[i] = true; } } } int find_best(int n) { try { if (n <= 5000) { for (int i=0; i<n; ++i) { auto [a, b] = Ask(i); if (a+b == 0) return i; } return -1; } lowest_rank = _get_lowest_rank(n); find_all_weirdos(0, n-1, lowest_rank, 0, 0); for (int i=0; i<n; ++i) if (weirdo[i]) { auto [a, b] = Ask(i); if (a+b == 0) return i; } return -1; } catch (int i) { return i; } }

Compilation message (stderr)

prize.cpp: In function 'void find_all_weirdos(int, int, int, int, int)':
prize.cpp:38:20: error: could not convert 'cache[l]' from 'pp' {aka 'std::pair<int, int>'} to 'bool'
   38 |         if (cache[l]) {
      |             ~~~~~~~^
      |                    |
      |                    pp {aka std::pair<int, int>}
prize.cpp:42:20: error: could not convert 'cache[r]' from 'pp' {aka 'std::pair<int, int>'} to 'bool'
   42 |         if (cache[r]) {
      |             ~~~~~~~^
      |                    |
      |                    pp {aka std::pair<int, int>}