#include <bits/stdc++.h>
using namespace std;
#define point pair<int,int>
#define x first
#define y second
#define double long double
#define int long long
double const pi=3.141592653589793;
double angle(point p1,point p2){
int deltaY = p2.y - p1.y;
int deltaX = p2.x - p1.x;
double dg = atan2(deltaY, deltaX) * 180 / pi;
if(dg<0)
dg+=360;
return dg;}
bool check(double a1,double a2){
if(a1<180)
return (a2<a1) || (a2>a1+180);
else
return (a2>a1-180);
}
double dist(point a,point b){
return sqrt(((a.x-b.x)*(a.x-b.x))+((a.y-b.y)*(a.y-b.y)));
}
double solve(vector<point> pts){
int n=pts.size();
if(n==1)
return 0;
else if(n==2)
return dist(pts[0],pts[1]);
for (int i = 0; i < n; ++i)
pts.push_back(pts[i]);
deque<point> v;
v.push_back(pts[0]);
v.push_back(pts[1]);
v.push_back(pts[2]);
double len=dist(pts[0],pts[1])+dist(pts[1],pts[2]);
double maxx=len;
int p1=0,p2=2;
while(p1<n){
int a1=angle(pts[p1],pts[p1+1]);
int a2=angle(pts[p2+1],pts[p2]);
if(a1!=a2 && check(a1,a2)){
len+=dist(pts[p2],pts[p2+1]);
p2++;
}
else{
len-=dist(pts[p1],pts[p1+1]);
p1++;
}
maxx=max(maxx,len);
}
return maxx;
}
signed main(){
int n;
cin>>n;
vector<point> pts(n);
for (int i = 0; i < n; ++i)
cin>>pts[i].x>>pts[i].y;
if(angle(pts[0],pts[1])>angle(pts[0],pts[2]))
reverse(pts.begin(), pts.end());
cout<<fixed;
cout<<setprecision(7)<<solve(pts)<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st numbers differ - expected: '34724.8554753593', found: '62583.2325834000', error = '0.8022604191' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st numbers differ - expected: '34724.8554753593', found: '62583.2325834000', error = '0.8022604191' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st numbers differ - expected: '32934.3604541195', found: '61565.4576690000', error = '0.8693381872' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
1st numbers differ - expected: '1042655967.3918291330', found: '1533588.8182779001', error = '0.9985291516' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st numbers differ - expected: '34724.8554753593', found: '62583.2325834000', error = '0.8022604191' |
2 |
Halted |
0 ms |
0 KB |
- |