/**
* Author: Oleksandr Bacherikov, chilli
* Date: 2019-05-07
* License: Boost Software License
* Source: https://github.com/AlCash07/ACTL/blob/master/include/actl/geometry/algorithm/intersect/line_convex_polygon.hpp
* Description: Line-convex polygon intersection. The polygon must be ccw and have no collinear points.
* lineHull(line, poly) returns a pair describing the intersection of a line with the polygon:
* \begin{itemize*}
* \item $(-1, -1)$ if no collision,
* \item $(i, -1)$ if touching the corner $i$,
* \item $(i, i)$ if along side $(i, i+1)$,
* \item $(i, j)$ if crossing sides $(i, i+1)$ and $(j, j+1)$.
* \end{itemize*}
* In the last case, if a corner $i$ is crossed, this is treated as happening on side $(i, i+1)$.
* The points are returned in the same order as the line hits the polygon.
* \texttt{extrVertex} returns the point of a hull with the max projection onto a line.
* Time: O(\log n)
* Status: stress-tested
*/#pragma once
#include"src/geometry/Point.h"#define cmp(i,j) sgn(dir.perp().cross(poly[(i)%n]-poly[(j)%n]))
#define extr(i) cmp(i + 1, i) >= 0 && cmp(i, i - 1 + n) < 0
template<classP>intextrVertex(vector<P>&poly,Pdir){intn=sz(poly),lo=0,hi=n;if(extr(0))return0;while(lo+1<hi){intm=(lo+hi)/2;if(extr(m))returnm;intls=cmp(lo+1,lo),ms=cmp(m+1,m);(ls<ms||(ls==ms&&ls==cmp(lo,m))?hi:lo)=m;}returnlo;}#define cmpL(i) sgn(a.cross(poly[i], b))
template<classP>array<int,2>lineHull(Pa,Pb,vector<P>&poly){intendA=extrVertex(poly,(a-b).perp());intendB=extrVertex(poly,(b-a).perp());if(cmpL(endA)<0||cmpL(endB)>0)return{-1,-1};array<int,2>res;rep(i,0,2){intlo=endB,hi=endA,n=sz(poly);while((lo+1)%n!=hi){intm=((lo+hi+(lo<hi?0:n))/2)%n;(cmpL(m)==cmpL(endB)?lo:hi)=m;}res[i]=(lo+!cmpL(hi))%n;swap(endA,endB);}if(res[0]==res[1])return{res[0],-1};if(!cmpL(res[0])&&!cmpL(res[1]))switch((res[0]-res[1]+sz(poly)+1)%sz(poly)){case0:return{res[0],res[0]};case2:return{res[1],res[1]};}returnres;}
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/LineHullIntersection.h:line20:#pragmaoncefoundinanon-firstline