#ifndef INCLUDE_MODE #define INCLUDE_MODE // #define REACTIVE // #define USE_GETLINE /* #define SUBMIT_ONLY */ #define DEBUG_OUTPUT #define SAMPLE_CHECK F #endif #ifdef INCLUDE_MAIN VO Solve() { CIN( int , N ); using entry_type = T2; CIN_A( entry_type , 0 , N , XY ); ConvexHull ch{ XY }; auto& S = ch.ExtremalPointIndex(); WHAT( S ); auto& ext_cyc = ch.CyclicOrderedExtremalPoints(); FOR( i , 0 , N ){ if( !In( i , S ) ){ COUT( "No" ); } else if( len( S ) == 2 ){ int i0 = Min( S ) , i1 = Max( S ); int A = XY[i0][O] - XY[i1][O] , B = XY[i0][I] - XY[i1][I]; if( A * XY[i][O] + B * XY[i][I] < max( A * XY[i0][O] + B * XY[i0][I] , A * XY[i1][O] + B * XY[i1][I] ) ){ A *= -1; B *= -1; } COUT( A , B ); } else { FOR( b , 0 , 2 ){ int x = XY[i][O] * ( b ? -1 : 1 ); int y = XY[i][I] * ( b ? -1 : 1 ); if( !In( tuple{b,x,y,i} , ext_cyc ) ){ continue; } auto itr = ext_cyc.lower_bound( tuple{b,x,y,i} ) , prev = itr , next = itr; ch.Decr( prev ); ch.Incr( next ); auto& [b0,x0,y0,i0] = *prev; auto& [b1,x1,y1,i1] = *next; int A = ( b0 ? -y0 : y0 ) - ( b1 ? -y1 : y1 ) , B = ( b1 ? -x1 : x1 ) - ( b0 ? -x0 : x0 ); if( A * XY[i][O] + B * XY[i][I] < max( A * XY[i0][O] + B * XY[i0][I] , A * XY[i1][O] + B * XY[i1][I] ) ){ A *= -1; B *= -1; } COUT( A , B ); } } } } REPEAT_MAIN(1e5); #else /* INCLUDE_MAIN */ #ifdef INCLUDE_SUB // /* COMPAREに使用。圧縮時は削除する。*/ // using answer_type = ll; // answer_type Naive( int N , int M , int K , const vector& A , const bool& debug_output = true ) // { // answer_type a{}; // return a; // } // // answer_type Answer( int N , int M , int K , const vector& A , const bool& debug_output = true ) // { // answer_type a{}; // return a; // } /* 圧縮時は中身だけ削除する。*/ IN VO Experiment() { // 1変数 ../Contest/Template/Experiment/OneVariable.txt // 2変数 ../Contest/Template/Experiment/TwoVariable.txt // 3変数 ../Contest/Template/Experiment/ThreeVariable.txt } /* 圧縮時は中身だけ削除する。*/ IN VO SmallTest() { // 数 ../Contest/Template/SmallTest/Number.txt // 配列 ../Contest/Template/SmallTest/Array.txt // 順列 ../Contest/Template/SmallTest/Permutation.txt // 文字列 ../Contest/Template/SmallTest/String.txt // グリッド ../Contest/Template/SmallTest/Grid.txt // グラフ ../Contest/Template/SmallTest/Graph.txt // 重み付きグラフ ../Contest/Template/SmallTest/WeightedGraph.txt // 区間クエリ ../Contest/Template/SmallTest/IntervalQuery.txt CERR( "全てのケースを確認しました。" ); } /* 圧縮時は中身だけ削除する。*/ IN VO RandomTest( const int& test_case_num ) { // 数 ../Contest/Template/RandomTest/Number.txt // 配列 ../Contest/Template/RandomTest/Array.txt // 順列 ../Contest/Template/RandomTest/Permutation.txt // 文字列 ../Contest/Template/RandomTest/String.txt // グリッド ../Contest/Template/RandomTest/Grid.txt // グラフ ../Contest/Template/RandomTest/Graph.txt // 重み付きグラフ ../Contest/Template/RandomTest/WeightedGraph.txt // 区間クエリ ../Contest/Template/RandomTest/IntervalQuery.txt // 多種クエリ ../Contest/Template/RandomTest/MultiTypeQuery.txt REPEAT( test_case_num ){ } CERR( "全てのケースを確認しました。" ); } #define INCLUDE_MAIN #include __FILE__ #else /* INCLUDE_SUB */ #ifdef INCLUDE_LIBRARY /* VVV 常設でないライブラリは以下に挿入する。*/ // AffineSpace ../Contest/Template/Library/AffineSpace.txt // Arithmetic ../Contest/Template/Library/Arithmetic.txt // BFS ../Contest/Template/Library/BFS.txt // BIT ../Contest/Template/Library/BIT.txt // CoordinateCompress ../Contest/Template/Library/CoordinateCompress.txt // DFS ../Contest/Template/Library/DFS.txt // DifferenceSequence ../Contest/Template/Library/DifferenceSequence.txt // Dijkstra ../Contest/Template/Library/Dijkstra.txt // Knapsack ../Contest/Template/Library/Knapsack.txt // Matrix ../Contest/Template/Library/Matrix.txt // Set ../Contest/Template/Library/Set.txt // Polynomial ../Contest/Template/Library/Polynomial.txt // SqrtDecomposition ../Contest/Template/Library/SqrtDecomposition.txt // UnionFind ../Contest/Template/Library/UnionFind.txt #ifdef DEBUG #include "c:/Users/user/Documents/Programming/Mathematics/Geometry/AffineSpace/Polytope/Area/a_Body.hpp" #else #define DF_OF_AREA (x1 - x0)*(y2 - y0)-(y1 - y0)*(x2 - x0) #define CALL_DF_OF_AREA Area (get<0>(v0),get<1>(v0),get<0>(v1),get<1>(v1),get<0>(v2),get<1>(v2)) IN ll Area_ll(CRL x0,CRL y0,CRL x1,CRL y1,CRL x2,CRL y2){RE DF_OF_AREA;}TE IN ll Area(CO INT& x0,CO INT& y0,CO INT& x1,CO INT& y1,CO INT& x2,CO INT& y2){RE Area_ll(x0,y0,x1,y1,x2,y2);}IN double Area(CO double& x0,CO double& y0,CO double& x1,CO double& y1,CO double& x2,CO double& y2){RE DF_OF_AREA;}TE TY PAIR> IN ll Area(CO PAIR& v0,CO PAIR& v1,CO PAIR& v2){RE CALL_DF_OF_AREA;}TE TY PAIR> IN double Area(CO PAIR& v0,CO PAIR& v1,CO PAIR& v2){RE CALL_DF_OF_AREA;}TE TY PAIR,TY RET> IN RET Area(CO VE>& v,RET dummy){CRI SZ = v.SZ();AS(SZ > 2);for(int i = 2;i < SZ;i++){dummy += Area(v[0],v[i-1],v[i]);}RE MO(dummy);} #endif template typename PAIR> class ConvexHull { private: int m_size; // {上側?0:1,±x,±y,格納順の番号}を管理することで // 上側をx昇順、下側をx降順に並べる。(つまり時計回り) set> m_ext_cyc; // int値はいずれも格納順。 set m_ext; vector m_non_ext_end; vector m_interior; public: inline ConvexHull() = default; template