Submission #293140

#TimeUsernameProblemLanguageResultExecution timeMemory
293140SaboonThe Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int Max = 0; const int maxn = 2e5 + 10; vector<int> Q[maxn]; bool mark[maxn]; vector<int> Ask(int i){ if (mark[i]) return Q[i]; mark[i] = 1; return Q[i] = ask(i); } int solve(int l, int r, int cnt, int pre = 0, int suf = 0){ if (cnt <= 0 or l >= r) return -1; if (l+1 == r){ vector<int> res = Ask(l); if (res[0]+res[1] == 0) return l; return -1; } vector<int> Vals; int m = (l+r)>>1; Vals.push_back(m); for (int i = 1; ;i++){ bool found = 0; if (m+i < r) found = 1, Vals.push_back(m+i); if (m-i >= l) found = 1, Vals.push_back(m-i); if (!found) break; } int Mn = m, Mx = m; for (auto mid : Vals){ Mn = min(Mn, mid); Mx = max(Mx, mid); vector<int> res = Ask(mid); if (res[0]+res[1] == 0) return mid; if (res[0]+res[1] == Max){ int ret = solve(l,mn,res[0]-pre, pre, res[1]); if (ret != -1) return ret; return solve(mx+1, r, res[1]-suf, res[0], suf); } } return -1; } int find_best(int n){ for (int i = 0; i < min(n,400); i++){ vector<int> res = Ask(i); Max = max(Max, res[0]+res[1]); if (Max >= 1000) break; } return solve(0, n, Max); }

Compilation message (stderr)

prize.cpp: In function 'int solve(int, int, int, int, int)':
prize.cpp:47:31: error: 'mn' was not declared in this scope; did you mean 'Mn'?
   47 |             int ret = solve(l,mn,res[0]-pre, pre, res[1]);
      |                               ^~
      |                               Mn
prize.cpp:50:26: error: 'mx' was not declared in this scope; did you mean 'Mx'?
   50 |             return solve(mx+1, r, res[1]-suf, res[0], suf);
      |                          ^~
      |                          Mx