#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const int MAXK = (int) 1e5;
char dx[256], dy[256];
inline double dist(double x1, double y1, double x2, double y2) {
return 1.0 * (x1 - x2) * (x1 - x2) + 1.0 * (y1 - y2) * (y1 - y2);
}
inline void upd(double &mn, double &mx, double cur) {
mn = min(mn, cur);
mx = max(mx, cur);
}
string str;
double dst[MAXK + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, k;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> k >> str;
double lx, ly, gx, gy;
cin >> lx >> ly >> gx >> gy;
dx['L'] = -1, dx['R'] = 1;
dy['F'] = 1, dy['B'] = -1;
int x = 0, y = 0;
for(auto it : str) {
x += dx[it], y += dy[it];
}
double mn = 1e18, mx = 0;
if(x == 0 && y == 0) {
upd(mn, mx, dist(lx, ly, gx, gy));
for(auto it : str) {
x += dx[it], y += dy[it];
upd(mn, mx, dist(lx, ly, x + gx, y + gy));
}
cout << fixed << setprecision(20) << mn << " " << mx;
return 0;
}
int cx = gx, cy = gy;
dst[0] = mn = mx = dist(gx, gy, lx, ly);
for(i = 1; i <= k; i++) {
cx += x, cy += y;
dst[i] = dist(cx, cy, lx, ly);
upd(mn, mx, dst[i]);
}
cx = gx, cy = gy;
double mn1 = mn, mx1 = mx;
for(i = 0; i < k; i++) {
if(mn1 == dst[i] || mx1 == dst[i] || mn1 == dst[i + 1] || mx1 == dst[i + 1]) {
for(auto it : str) {
cx += dx[it], cy += dy[it];
upd(mn, mx, dist(cx, cy, lx, ly));
}
}
else {
cx += x, cy += y;
}
}
cout << fixed << setprecision(20) << mn << " " << mx;
//cin.close();
//cout.close();
return 0;
}
Compilation message
expgorl.cpp: In function 'int main()':
expgorl.cpp:40:19: warning: array subscript has type 'char' [-Wchar-subscripts]
x += dx[it], y += dy[it];
^
expgorl.cpp:40:32: warning: array subscript has type 'char' [-Wchar-subscripts]
x += dx[it], y += dy[it];
^
expgorl.cpp:46:23: warning: array subscript has type 'char' [-Wchar-subscripts]
x += dx[it], y += dy[it];
^
expgorl.cpp:46:36: warning: array subscript has type 'char' [-Wchar-subscripts]
x += dx[it], y += dy[it];
^
expgorl.cpp:64:28: warning: array subscript has type 'char' [-Wchar-subscripts]
cx += dx[it], cy += dy[it];
^
expgorl.cpp:64:42: warning: array subscript has type 'char' [-Wchar-subscripts]
cx += dx[it], cy += dy[it];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |