#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 ); FOR( i , 0 , N ){ auto& [x,y] = XY[i]; if( ch.Index( i ) == -1 ){ COUT( "No" ); } else if( len( S ) == 2 ){ int i0 = Min( S ) , i1 = Max( S ); auto& [x0,y0] = XY[i0]; auto& [x1,y1] = XY[i1]; ll A = x0 - x1 , B = y0 - y1; if( A * x + B * y < max( A * x0 + B * y0 , A * x1 + B * y1 ) ){ A *= -1; B *= -1; } COUT( A , B ); } else { auto& [x0,y0] = XY[ch.Prev( i )]; auto& [x1,y1] = XY[ch.Next( i )]; ll A = y0 - y1 , B = x1 - x0; assert( A * x0 + B * y0 == A * x1 + B * y1 ); if( A * x + B * y < A * x0 + B * y0 ){ A *= -1; B *= -1; } WHAT( x0 , y0 , x , y , x1 , y1 ); 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 class ArgumentSortOrder { private: INT m_x; INT m_y; public: inline ArgumentSortOrder( INT x , INT y ); template bool operator()( const PAIR& v0 , const PAIR& v1 ) const; }; template inline ArgumentSortOrder::ArgumentSortOrder( INT x , INT y ) : m_x( move( x ) ) , m_y( move( y ) ) {} template template inline bool ArgumentSortOrder::operator()( const PAIR& v0 , const PAIR& v1 ) const { auto& [x0,y0] = v0; auto& [x1,y1] = v1; assert( !( pair{x0,y0} < pair{m_x,m_y} ) && !( pair{x1,y1} < pair{m_x,m_y} ) ); const ll S = Area( m_x , m_y , x0 , y0 , x1 , y1 ); return S > 0 || ( S == 0 && ( x1 != m_x || y1 != m_y ) && ( ( x0 == m_x && y0 == m_y ) || y1 < y0 ) ); } template class ConvexHull { private: int m_size; // 格納順の番号を、反時計回りに格納する。 vector m_ext; Map m_ext_inv; vector m_non_ext_end; vector m_interior; public: // O(m_size log m_size) template