/**
* Author: black_horse2014, chilli
* Date: 2019-10-29
* License: Unknown
* Source: https://codeforces.com/gym/101673/submission/50481926
* Description: Calculates the area of the union of $n$ polygons (not necessarily
* convex). The points within each polygon must be given in CCW order.
* (Epsilon checks may optionally be added to sideOf/sgn, but shouldn't be needed.)
* Time: $O(N^2)$, where $N$ is the total number of points
* Status: stress-tested, Submitted on ECNA 2017 Problem A
*/#pragma once
#include"src/geometry/Point.h"
#include"src/geometry/sideOf.h"typedefPoint<double>P;doublerat(Pa,Pb){returnsgn(b.x)?a.x/b.x:a.y/b.y;}doublepolyUnion(vector<vector<P>>&poly){doubleret=0;rep(i,0,sz(poly))rep(v,0,sz(poly[i])){PA=poly[i][v],B=poly[i][(v+1)%sz(poly[i])];vector<pair<double,int>>segs={{0,0},{1,0}};rep(j,0,sz(poly))if(i!=j){rep(u,0,sz(poly[j])){PC=poly[j][u],D=poly[j][(u+1)%sz(poly[j])];intsc=sideOf(A,B,C),sd=sideOf(A,B,D);if(sc!=sd){doublesa=C.cross(D,A),sb=C.cross(D,B);if(min(sc,sd)<0)segs.emplace_back(sa/(sa-sb),sgn(sc-sd));}elseif(!sc&&!sd&&j<i&&sgn((B-A).dot(D-C))>0){segs.emplace_back(rat(C-A,B-A),1);segs.emplace_back(rat(D-A,B-A),-1);}}}sort(all(segs));for(auto&s:segs)s.first=min(max(s.first,0.0),1.0);doublesum=0;intcnt=segs[0].second;rep(j,1,sz(segs)){if(!cnt)sum+=segs[j].first-segs[j-1].first;cnt+=segs[j].second;}ret+=A.cross(B)*sum;}returnret/2;}
Traceback(mostrecentcalllast):File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/documentation/build.py",line71,in_render_source_code_statbundled_code=language.bundle(stat.path,basedir=basedir,options={'include_paths':[basedir]}).decode()~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus.py",line187,inbundlebundler.update(path)~~~~~~~~~~~~~~^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py",line312,inupdateraiseBundleErrorAt(path,i+1,"#pragma once found in a non-first line")onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt:src/geometry/PolygonUnion.h:line12:#pragmaoncefoundinanon-firstline