#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});
}*/
//cout<<x1<<" "<<y1<<endl;
for(int i=0;i<k;i++)
{
for(int j=0;j<s.size();j++)
{
if(s[j]=='R')x1++;
if(s[j]=='L')x1--;
if(s[j]=='F')y1++;
if(s[j]=='B')y1--;
maxdist=max(maxdist,sqrt(x1*x1+y1*y1));
mindist=min(mindist,sqrt(x1*x1+y1*y1));
//cout<<x1<<" "<<y1<<endl;
}
}
cout<<fixed<<setprecision(20)<<mindist<<" "<<fixed<<setprecision(20)<<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:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int j=0;j<s.size();j++)
| ~^~~~~~~~~
expgorl.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
393 ms |
272 KB |
Output is correct |
2 |
Correct |
498 ms |
280 KB |
Output is correct |
3 |
Correct |
557 ms |
272 KB |
Output is correct |
4 |
Correct |
598 ms |
328 KB |
Output is correct |
5 |
Correct |
292 ms |
208 KB |
Output is correct |
6 |
Correct |
449 ms |
272 KB |
Output is correct |
7 |
Correct |
544 ms |
296 KB |
Output is correct |
8 |
Correct |
688 ms |
292 KB |
Output is correct |
9 |
Execution timed out |
1093 ms |
208 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |