#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;
}
upd(mn, mx, dist(lx, ly, gx, gy));
while(k > 0) {
k--;
for(auto it : str) {
gx += dx[it], gy += dy[it];
upd(mn, mx, dist(lx, ly, gx, gy));
}
}
mn = sqrt(mn), mx = sqrt(mx);
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:56:24: warning: array subscript has type 'char' [-Wchar-subscripts]
gx += dx[it], gy += dy[it];
^
expgorl.cpp:56:38: warning: array subscript has type 'char' [-Wchar-subscripts]
gx += dx[it], gy += dy[it];
^
expgorl.cpp:30:9: warning: unused variable 'i' [-Wunused-variable]
int i, k;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
380 KB |
Output is correct |
2 |
Correct |
88 ms |
508 KB |
Output is correct |
3 |
Correct |
99 ms |
516 KB |
Output is correct |
4 |
Correct |
104 ms |
632 KB |
Output is correct |
5 |
Correct |
57 ms |
632 KB |
Output is correct |
6 |
Correct |
80 ms |
632 KB |
Output is correct |
7 |
Correct |
86 ms |
632 KB |
Output is correct |
8 |
Correct |
119 ms |
632 KB |
Output is correct |
9 |
Execution timed out |
1070 ms |
756 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |