double polygonDiameter( vector< PT> & p)
{
int n= SZ( p) ;
if ( n< 2 ) return 0 ;
else if ( n== 2 ) return distPoint( p[ 0 ] ,p[ 1 ] ) ; //distance between two points
else
{
int i= n- 1 ,j= 0 ,k= 1 ;
double res= 0 ;
while ( abs ( cross( p[ j] - p[ i] ,p[ k+ 1 ] - p[ i] ) >
abs ( cross( p[ j] - p[ i] ,p[ k] - p[ i] ) ) ) )
{
k++ ;
}
i= 0 ,j= k;
while ( i<= k && j< n)
{
res= max( distPoint( p[ i] ,p[ j] ) ,res) ;
while ( j< n- 1 && abs ( cross( p[ i+ 1 ] - p[ i] ,p[ j+ 1 ] - p[ i] ) >
abs ( cross( p[ i+ 1 ] - p[ i] ,p[ j] - p[ i] ) ) ) )
{
j++ ;
res= max( distPoint( p[ i] ,p[ j] ) ,res) ;
}
i++ ;
}
return res;
}
}
int main( )
{
#ifdef MAHDI
// Read;
// Write;
#endif // MAHDI
vector< PT> poly,cpoly; PT a;
int n;
sf( "%d" ,& n) ;
for ( int i= 0 ; i< n; i++ )
{
a.input ( ) ;
poly.psb ( a) ;
}
ConvexHull( poly,cpoly) ;
pf( "%.12f\n " ,polygonDiameter( cpoly) ) ;
return 0 ;
}
ZG91YmxlIHBvbHlnb25EaWFtZXRlcih2ZWN0b3I8UFQ+ICZwKQp7CiAgICBpbnQgbj1TWihwKTsKICAgIGlmKG48MikgcmV0dXJuIDA7CiAgICBlbHNlIGlmKG49PTIpIHJldHVybiBkaXN0UG9pbnQocFswXSxwWzFdKTsvL2Rpc3RhbmNlIGJldHdlZW4gdHdvIHBvaW50cwogICAgZWxzZQogICAgewogICAgICAgIGludCBpPW4tMSxqPTAsaz0xOwogICAgICAgIGRvdWJsZSByZXM9MDsKICAgICAgICB3aGlsZShhYnMoY3Jvc3MocFtqXS1wW2ldLHBbaysxXS1wW2ldKSA+CiAgICAgICAgICAgICAgICAgIGFicyhjcm9zcyhwW2pdLXBbaV0scFtrXS1wW2ldKSkpKQogICAgICAgIHsKICAgICAgICAgICAgaysrOwogICAgICAgIH0KICAgICAgICBpPTAsaj1rOwogICAgICAgIHdoaWxlKGk8PWsgJiYgajxuKQogICAgICAgIHsKICAgICAgICAgICAgcmVzPW1heChkaXN0UG9pbnQocFtpXSxwW2pdKSxyZXMpOwogICAgICAgICAgICB3aGlsZShqPG4tMSAmJiBhYnMoY3Jvc3MocFtpKzFdLXBbaV0scFtqKzFdLXBbaV0pID4KICAgICAgICAgICAgICAgICAgICAgIGFicyhjcm9zcyhwW2krMV0tcFtpXSxwW2pdLXBbaV0pKSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGorKzsKICAgICAgICAgICAgICAgIHJlcz1tYXgoZGlzdFBvaW50KHBbaV0scFtqXSkscmVzKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpKys7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICB9Cn0KCmludCBtYWluKCkKewogICAgI2lmZGVmIE1BSERJCi8vICAgIFJlYWQ7Ci8vICAgIFdyaXRlOwogICAgI2VuZGlmIC8vIE1BSERJCiAgICB2ZWN0b3I8UFQ+IHBvbHksY3BvbHk7UFQgYTsKICAgIGludCBuOwogICAgc2YoIiVkIiwmbik7CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgewogICAgICAgIGEuaW5wdXQoKTsKICAgICAgICBwb2x5LnBzYihhKTsKICAgIH0KICAgIENvbnZleEh1bGwocG9seSxjcG9seSk7CiAgICBwZigiJS4xMmZcbiIscG9seWdvbkRpYW1ldGVyKGNwb2x5KSk7CiAgICByZXR1cm4gMDsKfQ==
compilation info
prog.cpp:1:24: error: 'vector' was not declared in this scope
double polygonDiameter(vector<PT> &p)
^
prog.cpp:1:31: error: 'PT' was not declared in this scope
double polygonDiameter(vector<PT> &p)
^
prog.cpp:1:36: error: 'p' was not declared in this scope
double polygonDiameter(vector<PT> &p)
^
prog.cpp:2:1: error: expected ',' or ';' before '{' token
{
^
stdout