제출 #329127

#제출 시각아이디문제언어결과실행 시간메모리
329127PetiTriangles (CEOI18_tri)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> #include "trilib.h" using namespace std; int burok[(int)4e4], hely[(int)4e4]; int veg = 0; int main() { int n = get_n(); vector<int> vl, vr; for(int i = 3; i <= n; i++){ if(is_clockwise(1, 2, i)) vr.push_back(i); else vl.push_back(i); } sort(vr.begin(), vr.end(), [](int a, int b) {return is_clockwise(1, b, a);}); sort(vl.begin(), vl.end(), [](int a, int b) {return is_clockwise(1, b, a);}); vector<int> sor(n); int x = 0; sor[x++] = 1; for(int y : vr) sor[x++] = y; sor[x++] = 2; for(int y : vl) sor[x++] = y; burok[veg++] = sor[0]; burok[veg++] = sor[1]; for(int i = 2; i < n; i++){ int x = i%n; while(veg > 1 && is_clockwise(burok[veg-2], burok[veg-1], sor[x])) veg--; burok[veg++] = sor[x]; } while(veg > 1 && is_clockwise(burok[veg-2], burok[veg-1], sor[0])) veg--; for(int i = 0; i < n; i++) hely[sor[i]-1] = i; int s = 0; while(hely[burok[s]-1] < hely[1]) s++; s = hely[burok[s]-1]; burok[0] = sor[s]; burok[1] = sor[(s+1)%n]; veg = 2; for(int i = s+2; i < n+s; i++){ int x = i%n; while(veg > 1 && is_clockwise(burok[veg-2], burok[veg-1], sor[x])) veg--; burok[veg++] = sor[x]; } while(veg > 1 && is_clockwise(burok[veg-2], burok[veg-1], sor[s])) veg--; give_answer(veg); return 0; }

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

tri.cpp: In function 'int main()':
tri.cpp:14:5: error: 'vector' was not declared in this scope
   14 |     vector<int> vl, vr;
      |     ^~~~~~
tri.cpp:4:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    3 | #include "trilib.h"
  +++ |+#include <vector>
    4 | 
tri.cpp:14:12: error: expected primary-expression before 'int'
   14 |     vector<int> vl, vr;
      |            ^~~
tri.cpp:17:13: error: 'vr' was not declared in this scope
   17 |             vr.push_back(i);
      |             ^~
tri.cpp:19:13: error: 'vl' was not declared in this scope
   19 |             vl.push_back(i);
      |             ^~
tri.cpp:22:10: error: 'vr' was not declared in this scope
   22 |     sort(vr.begin(), vr.end(), [](int a, int b) {return is_clockwise(1, b, a);});
      |          ^~
tri.cpp:23:10: error: 'vl' was not declared in this scope
   23 |     sort(vl.begin(), vl.end(), [](int a, int b) {return is_clockwise(1, b, a);});
      |          ^~
tri.cpp:25:12: error: expected primary-expression before 'int'
   25 |     vector<int> sor(n);
      |            ^~~
tri.cpp:27:5: error: 'sor' was not declared in this scope; did you mean 'qsort'?
   27 |     sor[x++] = 1;
      |     ^~~
      |     qsort