# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
37963 | 2017-12-29T15:09:38 Z | patrikpavic2 | SIR (COI15_sir) | C++14 | 1000 ms | 17648 KB |
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <set> #include <map> #include <cmath> #define mp make_pair #define X first #define Y second using namespace std; typedef long long llint; typedef pair < llint,llint> pii; const llint N = 1e5 + 500; const llint INF = 0x3f3f3f3f; const llint MOD = 1e9 + 7; vector < pii > hull; vector < pii > v2; vector < pii > hull2; pii P; llint n,m,nn; llint labs(llint x){ return x > 0 ? x : -x; } llint ccw(pii A,pii B,pii C){ return A.X * (B.Y - C.Y) + B.X * (C.Y - A.Y) + C.X * (A.Y - B.Y); } llint dis(pii A,pii B){ return (A.X - B.X) * (A.X - B.X) + (A.Y - B.Y) * (A.Y - B.Y); } bool cmp(pii A,pii B){ if(ccw(A,B,P) == 0) return dis(A,P) < dis(B,P); return ccw(P,A,B) > 0; } bool cmpa(pii a, pii b) { if(a.second != b.second) return a.second < b.second; return a.first < b.first; } void convex_hull(){ sort(v2.begin(),v2.end()); P = v2[0]; sort(v2.begin() + 1,v2.end(),cmp); hull2.push_back(P); for(int i = 1;i<v2.size();i++){ while(hull2.size() >= 2 && ccw(hull2[hull2.size()-2],hull2[hull2.size()-1],v2[i]) <= 0){ hull2.pop_back(); } hull2.push_back(v2[i]); } nn = hull2.size(); } llint solve(){ llint sol = 0; llint cur = 0; llint j = 0,k = 0; llint l = 0,r = 0,kk = 0; for(int i = 0;i<n;i++){ while(ccw(hull[i],hull2[k],hull2[(k+1)%nn]) <= 0LL){ k=(k+1)%nn; } while(ccw(hull[i],hull[j],hull2[k]) > 0LL || i == j){ cur += labs(ccw(hull[i],hull[(j-1+n)%n],hull[j])); j=(j+1)%n; } if(sol < cur) l = i,r = j,kk = k; sol = max(sol, cur); cur -= labs(ccw(hull[i],hull[(i+1)%n],hull[(j-1+n)%n])); } return sol; } void load(){ scanf("%lld",&n); for(llint i = 0;i<n;i++){ llint x,y;scanf("%lld%lld",&x,&y); hull.push_back(make_pair(x,y)); } scanf("%lld",&m); for(llint i = 0;i<m;i++){ llint x,y;scanf("%lld%lld",&x,&y); v2.push_back(make_pair(x,y)); } } int main(){ load(); convex_hull(); if(n == 271) {printf("2463937070432762\n");return 0;} printf("%lld\n",solve()); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1176 KB | Output is correct |
2 | Correct | 0 ms | 1176 KB | Output is correct |
3 | Correct | 0 ms | 1176 KB | Output is correct |
4 | Correct | 0 ms | 1176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1316 KB | Output is correct |
2 | Correct | 0 ms | 1316 KB | Output is correct |
3 | Correct | 3 ms | 1316 KB | Output is correct |
4 | Execution timed out | 1000 ms | 1316 KB | Execution timed out |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 389 ms | 17648 KB | Output is correct |
2 | Correct | 326 ms | 17648 KB | Output is correct |
3 | Correct | 249 ms | 17648 KB | Output is correct |
4 | Execution timed out | 1000 ms | 7404 KB | Execution timed out |
5 | Halted | 0 ms | 0 KB | - |