#include<bits/stdc++.h>
using namespace std;
#define int long long
int k;
string s;
int dist(int gx, int gy, int lx, int ly)
{
return (gx-lx)*(gx-lx) + (gy-ly)*(gy-ly);
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>k>>s;
//k = min(k, 40000);
int gx,gy,lx,ly;
cin>>lx>>ly>>gx>>gy;
assert(lx<=10000);
assert(ly<=10000);
assert(gx<=10000);
assert(gy<=10000);
int mnm = dist(gx,gy,lx,ly), mxm = dist(gx,gy,lx,ly);
int poz=0;
int lim = k * (int)s.size();
for(int i=0;i<lim;i++)
{
if(s[poz]=='L')
{
gx--;
}
else if(s[poz]=='R')
{
gx++;
}
else if(s[poz]=='F')
{
gy++;
}
else if(s[poz]=='B')
{
gy--;
}
//if(abs(gx-lx) > 20000 || abs(gy-ly) > 20000)
// break;
mnm = min(mnm, dist(gx,gy,lx,ly));
mxm = max(mxm, dist(gx,gy,lx,ly));
poz++;
if(poz==(int)s.size())
poz=0;
}
long double d1 = sqrt(mnm);
long double d2 = sqrt(mxm);
cout<<fixed<<setprecision(10)<<d1<<" "<<d2;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
344 KB |
Output is correct |
2 |
Correct |
57 ms |
344 KB |
Output is correct |
3 |
Correct |
63 ms |
344 KB |
Output is correct |
4 |
Correct |
73 ms |
428 KB |
Output is correct |
5 |
Correct |
35 ms |
348 KB |
Output is correct |
6 |
Correct |
52 ms |
344 KB |
Output is correct |
7 |
Correct |
56 ms |
428 KB |
Output is correct |
8 |
Correct |
79 ms |
432 KB |
Output is correct |
9 |
Execution timed out |
1064 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |