#ifndef AFMT_COMPUTATION_GEOMETRY
#define AFMT_COMPUTATION_GEOMETRY
#include<cassert>
#include<iostream>// Caution: This computation geometry template is pure shit// because of the terrible math level of the author.// It will be rewritten some time.template<classT>structPoint{Tx,y;Point(void)=default;Point(TX,TY):x(X),y(Y){}inlinebooloperator==(constPointB){returnx==B.x&&y==B.y;}friendstd::ostream&operator<<(std::ostream&out,PointP){returnout<<"("<<P.x<<", "<<P.y<<")";}friendstd::istream&operator>>(std::istream&in,Point&P){returnin>>P.x>>P.y;}};template<classT>structLine{TA,B,C;// Ax + By + C = 0Line(void)=default;Line(Ta,Tb,Tc):A(a),B(b),C(c){}// Ax + By + C = 0Line(Tk,Tb):A(k),B(-1),C(b){}// y = kx + b};template<classT>inlineintsign(Tx){returnx==0?0:(x<0?-1:1);}template<classT>inlineboolparallel(Line<T>P,Line<T>Q){returnP.A*Q.B==P.B*Q.A;}template<classT>inlinePoint<T>intersect(Line<T>P,Line<T>Q){assert(!parallel(P,Q));returnPoint<T>{(P.C*Q.B-Q.C*P.B)/(Q.A*P.B-P.A*Q.B),(P.C*Q.A-Q.C*P.A)/(P.A*Q.B-Q.A*P.B)};}template<classT>inlineLine<T>get_line(Point<T>P,Point<T>Q){assert(!(P==Q));if(P.x==Q.x){returnLine<T>(-1,0,P.x);}elseif(P.y==Q.y){returnLine<T>(0,-1,P.y);}else{returnLine<T>(Q.y-P.y,P.x-Q.x,P.y*Q.x-P.x*Q.y);}}template<classT>inlineboolpoint_on_line(Point<T>P,Line<T>L){returnL.A*P.x+L.B*P.y+L.C==0;}template<classT>inlineTdis_square(Point<T>P,Point<T>Q){return(P.x-Q.x)*(P.x-Q.x)+(P.y-Q.y)*(P.y-Q.y);}#endif // AFMT_COMPUTATION_GEOMETRY
#line 1 "src/alfred/math/computation-geometry.hpp"
#include<cassert>
#include<iostream>// Caution: This computation geometry template is pure shit// because of the terrible math level of the author.// It will be rewritten some time.template<classT>structPoint{Tx,y;Point(void)=default;Point(TX,TY):x(X),y(Y){}inlinebooloperator==(constPointB){returnx==B.x&&y==B.y;}friendstd::ostream&operator<<(std::ostream&out,PointP){returnout<<"("<<P.x<<", "<<P.y<<")";}friendstd::istream&operator>>(std::istream&in,Point&P){returnin>>P.x>>P.y;}};template<classT>structLine{TA,B,C;// Ax + By + C = 0Line(void)=default;Line(Ta,Tb,Tc):A(a),B(b),C(c){}// Ax + By + C = 0Line(Tk,Tb):A(k),B(-1),C(b){}// y = kx + b};template<classT>inlineintsign(Tx){returnx==0?0:(x<0?-1:1);}template<classT>inlineboolparallel(Line<T>P,Line<T>Q){returnP.A*Q.B==P.B*Q.A;}template<classT>inlinePoint<T>intersect(Line<T>P,Line<T>Q){assert(!parallel(P,Q));returnPoint<T>{(P.C*Q.B-Q.C*P.B)/(Q.A*P.B-P.A*Q.B),(P.C*Q.A-Q.C*P.A)/(P.A*Q.B-Q.A*P.B)};}template<classT>inlineLine<T>get_line(Point<T>P,Point<T>Q){assert(!(P==Q));if(P.x==Q.x){returnLine<T>(-1,0,P.x);}elseif(P.y==Q.y){returnLine<T>(0,-1,P.y);}else{returnLine<T>(Q.y-P.y,P.x-Q.x,P.y*Q.x-P.x*Q.y);}}template<classT>inlineboolpoint_on_line(Point<T>P,Line<T>L){returnL.A*P.x+L.B*P.y+L.C==0;}template<classT>inlineTdis_square(Point<T>P,Point<T>Q){return(P.x-Q.x)*(P.x-Q.x)+(P.y-Q.y)*(P.y-Q.y);}