The problem becomes the dynamic add-on maintenance convex package when the issue is reversed offline.
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm > #include <iostream> #include <cctype> #include <set> #define REP (i, L, R) for (int i=l; i<=r; i++) # Define down (I, L, R) for (int i=l; i>=r; i--) #define MAXN 200009using namespace Std;inline int read () {int x=0, f=1; char Ch=getchar (), while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();} while (IsDigit (CH)) x=x*10+ch-' 0 ', Ch=getchar (); return x*f;} struct p{int x, y;} a[200005], del[100005];d ouble dis (p A, p b) {return sqrt ((double) (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (a.y-b . y));} P operator-(p a, p B) {return (p) {a.x-b.x, a.y-b.y};} Double operator * (p a, p b) {return a.x*b.y-a.y*b.x;} BOOL operator < (p A, p b) {if (a.x==b.x) return a.y<b.y; else return a.x<b.x; Set<p> q;int N, M, Q, B[MAXN], T1, t2;double now=0, Res[maxn];bool mark[maxn];void Insert (p p) {Set<p>::iterato R R=q.lower_bound (p), l=r, T; L--;if ((*r-*l) * (p-*l) <0) Return;now-=dIs (*l, *r), while (1) {t=r++;if (R==q.end ()) break;if ((*r-p) * (*t-p) >0) Break;now-=dis (*t, *r); Q.erase (t);} while (L!=q.begin ()) {t=l--;if ((*t-p) * (*l-p) >0) Break;now-=dis (*t, *l); Q.erase (t);} Q.insert (P); L=r=q.find (P); l--; R++;now+=dis (*l, p) +dis (*r, p);} int main () {n=read (); Q.insert ((p) {0, 0}); Q.insert ((p) {n, 0}); P Bas;bas.x=read (); Bas.y=read (), Q.insert (BAS), Now+=dis ((p) {0, 0}, BAS) +dis ((p) {n, 0}, BAS), M=read (); Rep (I, 1, m) a[i].x=read (), a[i].y= Read (); Q=read (); Rep (i, 1, Q) {int type=read (), X;if (type==1) X=read (), del[++t1]=a[x], Mark[x]=1;else b[++t2]=t1;} Rep (i, 1, m) if (!mark[i]) insert (a[i]), int t=t1;down (i, T2, 1) {while (T>b[i]) insert (del[t--]); res[i]=now;} Rep (i, 1, T2) printf ("%.2lf\n", Res[i]); return 0;}
BZOJ-2300 [HAOI2011] Line construction