제출 #400927

#제출 시각아이디문제언어결과실행 시간메모리
400927jenkinsserPlanine (COCI21_planine)C++17
0 / 110
3 ms892 KiB
#include <bits/stdc++.h> #define FOR(ii,aa,bb) for(int ii=aa;ii<bb;ii++) #define for0(ii,bb) FOR(ii,0,bb) #define for1(ii,bb) FOR(ii,1,bb+1) #define pb push_back #define ppb pop_back #define mp make_pair #define st first #define nd second #define pii pair<int,int> #define piii pair<int,pii> #define piiii pair<pii,pii> #define pdi pair<double,int> #define vi vector<int> #define sp " " #define nl "\n" #define all(x) x.begin(),x.end() #define fastio() ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define int ll using namespace std; const int N = 1e5+5; const int INF = 1e9+5; const int mod = 998244353; int n,h; vector<pii> p; bool ccw(pii x,pii y,pii z){ return x.st*(y.nd-z.nd)+y.st*(z.nd-x.nd)+z.st*(x.nd-y.nd)>0; } bool cw(pii x,pii y,pii z){ return x.st*(y.nd-z.nd)+y.st*(z.nd-x.nd)+z.st*(x.nd-y.nd)<0; } vector<pii> compute1(){ vector<pii> hull; vector<pii> v; for(int i=2;i<n;i++){ while(hull.size()>=2&&ccw(hull[(int)hull.size()-2],hull[(int)hull.size()-1],p[i])) hull.pop_back(); hull.pb(p[i]); if(i&1){ pii a=hull[(int)hull.size()-1]; pii b=hull[(int)hull.size()-2]; // cout << a.st << sp << a.nd << sp << b.st << sp << b.nd << sp; pii c={(a.st-b.st)*(h-b.nd)+b.st*(a.nd-b.nd),a.nd-b.nd}; // cout << c.st << sp << c.nd << nl; v.pb(c); } } return v; } vector<pii> compute2(){ vector<pii> hull; vector<pii> v; for(int i=2;i<n;i++){ while(hull.size()>=2&&cw(hull[(int)hull.size()-2],hull[(int)hull.size()-1],p[i])) hull.pop_back(); hull.pb(p[i]); if(i&1){ pii a=hull[(int)hull.size()-1]; pii b=hull[(int)hull.size()-2]; // cout << a.st << sp << a.nd << sp << b.st << sp << b.nd << sp; pii c={(a.st-b.st)*(h-b.nd)+b.st*(a.nd-b.nd),a.nd-b.nd}; // cout << c.st << sp << c.nd << nl; v.pb(c); } } return v; } signed main(){ fastio() cin >> n >> h; p.resize(n+2); for(int i=1;i<=n;i++) cin >> p[i].st >> p[i].nd; vector<pii> a=compute1(); reverse(all(p)); vector<pii> b=compute2(); reverse(all(b)); vector<pii> v; for(int i=0;i<(int)a.size();i++){ v.pb({ceil((float)a[i].st/a[i].nd),b[i].st/b[i].nd}); } sort(all(v)); int last=v[0].nd; int ans=1; for(int i=1;i<(int)v.size();i++){ if(last<v[i].st){ ans++; last=v[i].nd; } } cout << ans << nl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...