Submission #103159

#TimeUsernameProblemLanguageResultExecution timeMemory
103159bert30702The Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "prize.h" #define pii pair<int, int> #define F first #define S second using namespace std; unordered_map<int, pii> mp; pii query(int p) { if(mp.find(p) != mp.end()) return mp[p]; vector<int> v = ask(p); return mp[p] = {v[0], v[1]}; } vector<pii> ans; void dfs(int l, int r, pii a, pii b, int mx) { if(l == r) return ans.push_back({b.F + b.S, l}); if(a == b) return; int m = l + r >> 1; pii v = query(m); if(v.F + v.S != mx) { ans.push_back({v.F + v.S, m}); if(m != l) dfs(l, m - 1, a, query(m - 1), mx); if(m != r) dfs(m + 1, r, query(m + 1), b, mx); } else { if(v == a) return dfs(m + 1, r, v, b, mx); if(v == b) return dfs( l, m, a, v, mx); dfs( l, m, a, v, mx); dfs(m + 1, r, v, b, mx); } } int find_best(int n) { dfs(0, n - 1, query(0), query(n - 1)); for(auto it: ans) if(it.F == 0) return it.S; }

Compilation message (stderr)

prize.cpp: In function 'void dfs(int, int, std::pair<int, int>, std::pair<int, int>, int)':
prize.cpp:17:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int m = l + r >> 1;
          ~~^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:32:38: error: too few arguments to function 'void dfs(int, int, std::pair<int, int>, std::pair<int, int>, int)'
  dfs(0, n - 1, query(0), query(n - 1));
                                      ^
prize.cpp:14:6: note: declared here
 void dfs(int l, int r, pii a, pii b, int mx) {
      ^~~
prize.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^