제출 #119652

#제출 시각아이디문제언어결과실행 시간메모리
119652tjd229커다란 상품 (IOI17_prize)C++14
컴파일 에러
0 ms0 KiB
#include "prize.h" #include <vector> #define pii pair<int,int> using namespace std; const int seg = 446 int pre; int nc;//1+2+3+4 int call; vector<int> v[200000]; void my_ask(int i) { if (v[i].empty()) v[i] = ask(i),++call; } int search(int l,int r,int tgt) { int t = -1; while (l <= r) { int m = (l + r) >> 1; my_ask(m); if (v[m][0] + v[m][1] != nc) { t = m, r = m - 1; if (tgt == 1) return t; } else if (v[m][0] == pre) l = m + 1,tgt=v[m][0]-pre; else r = m - 1; } return t; } int find_best(int n) { if (n <= 5000) { for (int i = 0; i < n; ++i) { my_ask(i); if (v[i][0] + v[i][1] == 0) return i; } } vector<pii > g; int i = 0, j = seg-1; int last = 0; while (i < n) { if (j >= n) j = n-1; my_ask(j); int s = v[j][0] + v[j][1]; if (s == 0) return j; if (nc < s) nc = s; g.push_back({i,j}); i += seg; j += seg; } for (i = 0; i < n && call <= 447; ++i) { my_ask(i); int s = v[i][0] + v[i][1]; if (s == 0) return i; if (nc < s) nc = s; } for (;v[last].size();++last) { int s = v[last][0] + v[last][1]; if (nc > s) ++pre; } for (i = 0; i < g.size();) { int e = g[i].second; if (last < g[i].first) last = g[i].first; if (e < last || (v[e][0]+v[e][1]==nc&&v[e][0]==pre)) { ++i; continue; } int t = search(last,e,v[e][0]-pre); if (v[t][0] + v[t][1] == 0) return t; ++pre; last = t+1; } return 0; }

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

prize.cpp:6:1: error: expected ',' or ';' before 'int'
 int pre;
 ^~~
prize.cpp: In function 'int search(int, int, int)':
prize.cpp:22:23: error: 'pre' was not declared in this scope
   else if (v[m][0] == pre) l = m + 1,tgt=v[m][0]-pre;  
                       ^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:54:17: error: 'pre' was not declared in this scope
   if (nc > s) ++pre;
                 ^~~
prize.cpp:56:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < g.size();) {
              ~~^~~~~~~~~~
prize.cpp:59:50: error: 'pre' was not declared in this scope
   if (e < last || (v[e][0]+v[e][1]==nc&&v[e][0]==pre)) {
                                                  ^~~
prize.cpp:63:33: error: 'pre' was not declared in this scope
   int t = search(last,e,v[e][0]-pre);
                                 ^~~