제출 #103155

#제출 시각아이디문제언어결과실행 시간메모리
103155bert30702커다란 상품 (IOI17_prize)C++17
0 / 100
3189 ms1034932 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 == a) return dfs(m + 1, r, v, b, mx); if(v == b) return dfs(l, m - 1, a, v, mx); dfs( l, m, a, v, mx); dfs(m + 1, r, v, b, mx); } int find_best(int n) { srand(time(0)); pii tmp = query(0); int mx = max(mx, tmp.F + tmp.S); if(tmp.F == 0 and tmp.S == 0) return 0; dfs(0, n - 1, query(0), query(n - 1), mx); for(auto it: ans) if(it.F == 0) return it.S; }

컴파일 시 표준 에러 (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:31:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prize.cpp:27:6: warning: 'mx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int mx = max(mx, tmp.F + tmp.S);
      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...