#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define ld long double
#define int long long
#define nl "\n"
using namespace std;
using pii = pair<int, int>;
const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
const int MOD = (int)1e9 + 7;
const int M = (int)5e4 + 7;
int k, Lx, Ly, Gx, Gy, dx, dy;
string a;
ll mn, mx;
ll dist(int x1, int y1, int x2, int y2) {
return 1ll * (x1 - x2) * (x1 - x2) + 1ll * (y1 - y2) * (y1 - y2);
}
void upd(int curx, int cury, int x) {
mn = min(mn, dist(Gx + curx + x * dx, Gy + cury + x * dy, Lx, Ly));
mx = max(mx, dist(Gx + curx + x * dx, Gy + cury + x * dy, Lx, Ly));
}
void solve() {
cin >> k >> a >> Lx >> Ly >> Gx >> Gy;
mn = INF, mx = -INF;
for(auto x : a) {
if(x == 'L') dx++;
if(x == 'R') dx--;
if(x == 'F') dy++;
if(x == 'B') dy--;
}
int curx = 0, cury = 0;
for(auto x : a) {
if(x == 'L') curx++;
if(x == 'R') curx--;
if(x == 'F') cury++;
if(x == 'B') cury--;
for(int m1 = 0; m1 < k; ++m1)
upd(curx, cury, m1);
}
while(k--) {
for(auto x : a) {
if(x == 'L') Gx--;
if(x == 'R') Gx++;
if(x == 'F') Gy++;
if(x == 'B') Gy--;
mn = min(mn, dist(Gx, Gy, Lx, Ly));
mx = max(mx, dist(Gx, Gy, Lx, Ly));
}
}
cout << fixed << setprecision(9) << sqrt(mn) << ' ' << sqrt(mx) << nl;
}
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test = 1;
//cin >> test;
while(test--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
16 |
Incorrect |
6 ms |
340 KB |
Output isn't correct |
17 |
Incorrect |
7 ms |
340 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
332 KB |
Output isn't correct |
19 |
Incorrect |
8 ms |
340 KB |
Output isn't correct |
20 |
Incorrect |
9 ms |
340 KB |
Output isn't correct |