제출 #265173

#제출 시각아이디문제언어결과실행 시간메모리
265173arayi커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include "prize.h" #include <bits/stdc++.h> #define MP make_pair #define fr first #define sc second using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const int N = 2e5 + 55; vector <pair <int, int> > dz; bool col[N]; int mx, q; vector <int> ss[N]; int as(int a) { vector <int> fp if(ss[a].size() == 0) { q++; if(q == 9880) assert(0); fp = ask(a); ss[a] = fp; } else fp = ss[a]; if(fp[0] + fp[1] == 0) return 0; if(!col[a] && fp[0] + fp[1] < mx) { dz.push_back(MP(a, fp[0] + fp[1])); return 2; } int sm = 0; for(auto p : dz) if(p.fr < a && p.sc < fp[0] + fp[1]) sm++; if(fp[0] - sm > 0) return -1; return 1; } int find_best(int n) { for (int i = 0; i < 20; i++) { int i1 = rnd() % n; vector <int> fp = ask(i1); mx = max(mx, fp[0] + fp[1]); } while(true) { int l = 0, r = n - 1; while(l <= r) { int mid = (l + r)/2; int qr = 0; while(mid - qr >= 0 && col[mid - qr]) qr++; if(mid - qr < 0) { l = mid + 1; continue; } int sm = as(mid - qr); if(sm == 0) return mid - qr; if(sm == 2) { col[mid - qr] = true; break; } if(sm == 1) l = mid + 1; if(sm == -1) r = mid - qr - 1; } } }

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

prize.cpp: In function 'int as(int)':
prize.cpp:18:5: error: expected initializer before 'if'
   18 |     if(ss[a].size() == 0)
      |     ^~
prize.cpp:26:5: error: 'else' without a previous 'if'
   26 |     else fp = ss[a];
      |     ^~~~
prize.cpp:26:10: error: 'fp' was not declared in this scope; did you mean 'fr'?
   26 |     else fp = ss[a];
      |          ^~
      |          fr