Submission #705498

#TimeUsernameProblemLanguageResultExecution timeMemory
705498browntoadSIR (COI15_sir)C++14
100 / 100
179 ms41736 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast", "unroll-loops") using namespace std; #define ll long long #define int ll #define FOR(i,a,b) for (int i = (a); i<(b); i++) #define REP(i,n) FOR(i,0,n) #define REP1(i,n) FOR(i,1,n+1) #define RREP(i,n) for (int i=(n)-1; i>=0; i--) #define f first #define s second #define pb push_back #define ALL(x) x.begin(),x.end() #define SZ(x) (int)(x.size()) #define SQ(x) (x)*(x) #define pii pair<int, int> #define pdd pair<double ,double> #define pcc pair<char, char> #define endl '\n' //#define TOAD #ifdef TOAD #define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl #define IOS() #else #define bug(...) #define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #endif const ll inf = 1ll<<60; const int iinf=2147483647; const ll mod = 1e9+7; const ll maxn=1e5+5; const double PI=acos(-1); ll pw(ll x, ll p, ll m=mod){ ll ret=1; while (p>0){ if (p&1){ ret*=x; ret%=m; } x*=x; x%=m; p>>=1; } return ret; } ll inv(ll a, ll m=mod){ return pw(a,m-2); } //======================================================================================= struct Point{ int x, y; int operator *(Point b){ return x*b.y-y*b.x; } Point operator -(Point b){ return {x-b.x, y-b.y}; } }; bool cmp(Point a, Point b){ if (a.x == b.x) return a.y<b.y; return a.x<b.x; } int n, m; int cid, pid; vector<Point> C, P; // cheese and pepper int area(Point a, Point b, Point c){ return abs((b-a)*(c-a)); } vector<Point> low_hull(vector<Point> a){ // assume alr sorted vector<Point> tmp; REP(i, SZ(a)){ while(SZ(tmp)>=2 && ((a[i]-tmp[SZ(tmp)-1])*(tmp[SZ(tmp)-2]-tmp[SZ(tmp)-1])) < 0){ tmp.pop_back(); } tmp.pb(a[i]); } tmp.pop_back(); return tmp; } vector<Point> convex_hull(vector<Point> a){ sort(ALL(a), cmp); if (SZ(a) == 1) return a; vector<Point> hull = low_hull(a); reverse(ALL(a)); vector<Point> tmp = low_hull(a); REP(i, SZ(tmp)) hull.pb(tmp[i]); return hull; } signed main (){ IOS(); cin>>n; REP(i, n){ int x, y; cin>>x>>y; C.pb({x, y}); } int m; cin>>m; REP(i, m){ int x, y; cin>>x>>y; P.pb({x, y}); } P=convex_hull(P); m=SZ(P); cid = 1; pid=0; REP(j, m){ if (((P[j]-C[0])*(P[pid]-C[0])) > 0) pid = j; } int carea = 0, res = 0; REP(i, n){ while(((P[(pid+1)%m]-C[i])*(P[pid]-C[i])) > 0) { pid = (pid+1)%m; } while(cid!=i && ((C[cid]-C[i])*(P[pid]-C[i])) > 0){ carea += area(C[i], C[(cid-1+n)%n], C[cid]); cid = (cid+1)%n; } res = max(res, carea); carea -= area(C[(cid-1+n)%n], C[i], C[(i+1)%n]); } cout<<res<<endl; } /* 0:24 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...