Submission #102757

#TimeUsernameProblemLanguageResultExecution timeMemory
102757bert30702The Big Prize (IOI17_prize)C++17
0 / 100
3 ms312 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<pair<int, pii> > ans; void dfs(int l, int r, pii a, pii b, int mx) { if(l == r) { if(b.F + b.S != mx) return ans.push_back({l, b}); return; } if(a == b) return; int m = l + r >> 1; pii v = query(m); 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) { srand(time(0)); int mx = 0; for(int i = 0; i < 10; i ++) { pii tmp = query(rand() % n); mx = max(mx, tmp.F + tmp.S); } dfs(0, n - 1, query(0), query(n - 1), mx); pii mn = {-1, mx}; for(auto it: ans) mn = min(mn, pii{it.S.F + it.S.S, it.F}); return mn.S; }

Compilation message (stderr)

prize.cpp: In function 'void dfs(int, int, std::pair<int, int>, std::pair<int, int>, int)':
prize.cpp:20:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int m = l + r >> 1;
          ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...