#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll tx, ty, lx, ly, gx, gy, k, si;
string s;
ld calc(ll xi, ll yi, ll xxi, ll yyi){
return abs(xi-xxi)*abs(xi-xxi)+abs(yi-yyi)*abs(yi-yyi);
}
int main(){
cin >> k >> s;
cout << fixed << setprecision(12);
si = s.size();
for(auto x : s){
if(x == 'L') tx--;
else if(x == 'R') tx++;
else if(x == 'F') ty++;
else if(x == 'B') ty--;
}
cin >> lx >> ly >> gx >> gy;
ld mni = calc(gx, gy, lx, ly);
ld mxi = max(calc(gx, gy, lx, ly), calc(lx, ly, gx+tx*(k-1), gy+ty*(k-1)));
for(int i = 0; i < si; i++){
ll lo = 0;
ll hi = k;
ll mid = (lo+hi)/2;
while(lo < hi){
mid = (lo+hi)/2;
ld xc = gx + tx*mid; //nakon mid*s
ld yc = gy + ty*mid; //nakon mid*s
ld xd = gx + tx*(mid+1); //jos jedan dalje
ld yd = gy + ty*(mid+1);
if(calc(lx, ly, xc, yc) < calc(lx, ly, xd, yd)){
hi = mid;
} else {
lo = mid+1;
}
}
mxi = max(mxi, max(calc(gx, gy, lx, ly), calc(lx, ly, gx+tx*(k-1), gy+ty*(k-1))));
mni = min(mni, calc(lx, ly, gx + tx*mid, gy+ty*mid));
char so = s[i];
if(so == 'L') gx--;
else if(so == 'R') gx++;
else if(so == 'F') gy++;
else if(so == 'B') gy--;
}
cout << sqrt(mni) << ' ' << sqrt(mxi);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |