제출 #247177

#제출 시각아이디문제언어결과실행 시간메모리
247177hhh07커다란 상품 (IOI17_prize)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #include <set> #include <cmath> #include <cstring> #include "prize.h" using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<ll, ll> ii; int maxi = -1; vi mem[(int)2e5 + 1]; bool done[(int)2e5 + 1]; vi pitaj(int idx){ if (done[idx]) return mem[idx]; done[idx] = true; return mem[idx] = ask(idx); } int smanji(int x, int y, int t){ while(y > t*x){ vi r = pitaj(y); if (r[0] + r[1] == 0) return -y; if (r[0] + r[1] == maxi) break; y--; } return y; } int bin_search(int lijevo, int beg, int end, int maxi){ if (beg > end) return -1; return -1; int l = beg, r = end; vi t; while(l < r){ int mid = (l + r)/2; t = pitaj(mid); if (t[0] + t[1] == 0) return mid; if (t[0] + t[1] == maxi){ if (lijevo - t[1]) r = mid - 1; else l = mid + 1; } else r = mid; } l = smanji(end, l, -1); if (l < 0) return -l; if (mem[l][1] - mem[end + 1][1]) return solve(mem[l][1], l + 1, end, maxi); return -1; } int find_best(int n){ memset(done, false, sizeof done); int maxi, grupa = 460, br = n/460; int curr = 0; vi idx; for (int i = 0; i < grupa; i++){ vi res = pitaj(curr); maxi = max(maxi, res[0] + res[1]); if (res[0] + res[1] == 0) return curr; idx.push_back(curr); curr += br; if (i < n%360) curr++; } done[n] = true; mem[n] = {maxi, 0}; idx.push_back(n); vi r; for (int i = 0; i < idx.size() - 1; i++){ int x = idx[i], y = idx[i + 1]; int res = -1; y = smanji(x, y, 1); x = smanji(y, x, -1); if (x < 0) return -x; if (y < 0) return -y; if (x < y) if (mem[x][1] - mem[y][1]) res = solve(mem[x][1], x + 1, y - 1, maxi); if ((res + 1)) return res; } }

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int bin_search(int, int, int, int)':
prize.cpp:63:16: error: 'solve' was not declared in this scope
         return solve(mem[l][1], l + 1, end, maxi);
                ^~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:87:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < idx.size() - 1; i++){
                     ~~^~~~~~~~~~~~~~~~
prize.cpp:97:23: error: 'solve' was not declared in this scope
                 res = solve(mem[x][1], x + 1, y - 1, maxi);
                       ^~~~~
prize.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^