제출 #74336

#제출 시각아이디문제언어결과실행 시간메모리
74336dsabolicSIR (COI15_sir)C++17
0 / 100
1062 ms3608 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const int N = 1e5 + 50; pll pivot; int n, m; pll points[N]; pll peppers[N]; vector<pll> hull; ll gccw(pll a, pll b, pll c) { return a.X * (b.Y - c.Y) + b.X * (c.Y - a.Y) + c.X * (a.Y - b.Y); } int ccw(pll a, pll b, pll c) { ll get = gccw(a, b, c); if(get > 0) return -1; else if(!get) return 0; return 1; } ll pow(ll a) { return a * a; } ll dist(pll a, pll b) { return pow(a.Y - b.Y) + pow(a.X - b.X); } bool cmpconvex(pll a, pll b) { int get = ccw(pivot, a, b); if(!get) return dist(pivot, a) < dist(pivot, b); return get == -1; } bool cmp(pll a, pll b) { if(a.Y == b.Y) return a.X < b.X; return a.Y < b.Y; } void cons_convex() { int idx = 0; for(int i = 1; i < m; ++i) if(cmp(peppers[i], peppers[idx])) idx = i; swap(peppers[0], peppers[idx]); pivot = peppers[0]; sort(peppers + 1, peppers + m, cmpconvex); if(m == 1) { hull.push_back(peppers[0]); return; } hull.push_back(peppers[0]); hull.push_back(peppers[1]); for(int i = 2; i < m; ++i) { pll top = hull.back(); hull.pop_back(); while(!hull.empty() && ccw(hull.back(), top, peppers[i]) != -1) top = hull.back(), hull.pop_back(); hull.push_back(top); hull.push_back(peppers[i]); } } int next(int i) { return (i + 1) % hull.size(); } int nextj(int i) { return (i + 1) % n; } ll area(pll a, pll b, pll c) { return llabs(gccw(a, b, c)); } void load_solve() { scanf("%d", &n); for(int i = 0; i < n; ++i) scanf("%lld%lld", &points[i].X, &points[i].Y); scanf("%d", &m); for(int i = 0; i < m; ++i) scanf("%lld%lld", &peppers[i].X, &peppers[i].Y); cons_convex(); int j = 1, k = 0; ll maxarea = 0, curr_area = 0; for(int i = 0; i < n; ++i) { // fiskiramo pocetak reza if(i == j) j = nextj(j); while(ccw(points[i], hull[k], hull[next(k)]) != -1) k = next(k); while(ccw(points[i], hull[k], points[nextj(j)]) > 0) { curr_area += area(points[i], points[j], points[nextj(j)]), j = nextj(j); } // printf("I: %d, J: %d, K: %d, AREA: %lld\n", i, j, k, curr_area); maxarea = max(maxarea, curr_area); if(i < n - 1) curr_area -= area(points[i], points[i + 1], points[j]); } printf("%lld\n", maxarea); } int main() { load_solve(); return 0; }

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

sir.cpp: In function 'void load_solve()':
sir.cpp:100:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
sir.cpp:102:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &points[i].X, &points[i].Y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sir.cpp:104:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
sir.cpp:106:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &peppers[i].X, &peppers[i].Y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...