發表文章

目前顯示的是有「有像面積」標籤的文章

[TIOJ] 1280. 領土 (Territory)

題目連結: http://tioj.infor.org/problems/1280 應該很明顯就是要求個凸包的面積,那就先求個凸包,求法就是先求出上凸包,再求下凸包,看上下凸包的方法也不難,就看看兩個相鄰的邊的夾角是不是超過180度就好。接著要求面積就直接算個有向面積加起來,而因為剛剛求凸包的順序關西,我們求有向面積的時候甚至不需要極角排序,直接求就好了。 #include <bits/stdc++.h> using namespace std; typedef long long lld; typedef pair<lld,lld> PLL; #define FF first #define SS second const int N = 10000 + 5; inline PLL operator-(const PLL &a, const PLL &b){ return {a.FF-b.FF, a.SS-b.SS}; } inline lld cross(const PLL &a, const PLL &b){ return a.FF*b.SS - b.FF*a.SS; } inline lld cross(const PLL &o, const PLL &a, const PLL &b){ return cross(a-o, b-o); } PLL arr[N]; vector<PLL> hull1, hull2; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; for(int i=0;i<n;i++) cin>>arr[i].FF>>arr[i].SS; sort(arr, arr+n); for(int i=0;i<n;i++){ w...