#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define y1 fddsfdsd
const ld INF=2e18;
int k;
string s;
struct point
{
ld x,y;
};
vector<point>v;
ld x1,y1,xa,ya;
ld mindist=INF,maxdist=-INF;
ld calcdist(point p1,ld t)
{
ld xx=p1.x+t*xa;
ld yy=p1.y+t*ya;
return sqrt(xx*xx+yy*yy);
}
ld ts(point p)
{
int l=0,r=k-1,m1,m2;
while(r-l>1000)
{
m1=l+(r-l)/3;
m2=l+2*(r-l)/3;
if(calcdist(p,m1)>=calcdist(p,m2))
{
l=m1;
}
else r=m2;
}
ld ret=INF;
for(int i=l;i<=r;i++)
{
ret=min(ret,calcdist(p,i));
}
return ret;
}
int main()
{
cin>>k;
cin>>s;
int xl,yl,xg,yg;
cin>>xl>>yl;
cin>>xg>>yg;
x1=xg-xl;y1=yg-yl;
/*v.push_back({x1,y1});
for(int i=0;i<s.size();i++)
{
if(s[i]=='R')x1++;
if(s[i]=='L')x1--;
if(s[i]=='F')y1++;
if(s[i]=='B')y1--;
v.push_back({x1,y1});
}*/
for(int i=0;i<k;i++)
{
for(int j=0;j<s.size();j++)
{
if(s[i]=='R')x1++;
if(s[i]=='L')x1--;
if(s[i]=='F')y1++;
if(s[i]=='B')y1--;
maxdist=max(maxdist,sqrt(x1*x1+y1*y1));
mindist=min(mindist,sqrt(x1*x1+y1*y1));
}
}
cout<<fixed<<setprecision(20)<<mindist<<" "<<maxdist<<endl;
return 0;
xa=x1;ya=y1;
ld mindist1=INF,maxdist1=-INF;
//cout<<xa<<" "<<ya<<endl;
for(int i=0;i<v.size();i++)
{
//cout<<v[i].x<<" "<<v[i].y<<endl;
mindist=min(mindist,ts(v[i]));
maxdist=max(maxdist,calcdist(v[i],0));
maxdist=max(maxdist,calcdist(v[i],k-1));
for(int j=0;j<k;j++)
{
mindist1=min(mindist1,calcdist(v[i],j));
maxdist1=max(maxdist1,calcdist(v[i],j));
}
//cout<<calcdist(v[i],0)<<" "<<calcdist(v[i],k-1)<<endl;
//cout<<maxdist<<endl;
}
//cout<<fixed<<setprecision(11)<<mindist<<" "<<maxdist<<endl;
cout<<fixed<<setprecision(15)<<mindist1<<" "<<maxdist1<<endl;
return 0;
}
Compilation message
expgorl.cpp: In function 'int main()':
expgorl.cpp:60:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int j=0;j<s.size();j++)
| ~^~~~~~~~~
expgorl.cpp:75:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
296 ms |
276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |