#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#define MAXN 100005
#define intt long long
#define f first
#define s second
using namespace std ;
intt k ;
long double sx , sy , gx , gy , fx , fy , mn = 23232323235 , mx ;
vector < pair < long double , long double > > d ;
string a ;
int main () {
cin >> k ;
cin >> a ;
cin >> sx >> sy >> gx >> gy ;
long double x = gx , y = gy ;
d.push_back ( make_pair ( x , y ) ) ;
for ( int i = 0 ; i < a.size () ; i ++ ) {
if ( a[i] == 'I' ) continue ;
if ( a[i] == 'L' ) x -- ;
if ( a[i] == 'R' ) x ++ ;
if ( a[i] == 'F' ) y ++ ;
if ( a[i] == 'B' ) y -- ;
d.push_back ( make_pair ( x , y ) ) ;
}
fx = x - gx ;
fy = y - gy ;
for ( int i = 0 ; i < d.size () ; i ++ ) {
x = d[i].f ;
y = d[i].s ;
long double prev = sqrt ( ( sx - x ) * ( sx - x ) + ( sy - y ) * ( sy - y ) ) , now ;
intt z = k ;
mn = min ( mn , prev ) ;
do {
prev = now ;
x += fx ;
y += fy ;
now = sqrt ( ( sx - x ) * ( sx - x ) + ( sy - y ) * ( sy - y ) ) ;
mn = min ( mn , now ) ;
mx = max ( mx , now ) ;
}while ( prev > now and z -- ) ;
}
for ( int i = 0 ; i < d.size () ; i ++ ) {
x = d[i].f ;
y = d[i].s ;
x += ( k - 1 ) * fx ;
y += ( k - 1 ) * fy ;
long double h = sqrt ( ( sx - x ) * ( sx - x ) + ( sy - y ) * ( sy - y ) ) ;
mx = max ( mx , h ) ;
}
cout << fixed << setprecision ( 12 ) ;
cout << mn << " " << mx << endl ;
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1880 KB |
Output isn't correct |
3 |
Correct |
0 ms |
1880 KB |
Output is correct |
4 |
Correct |
2 ms |
1880 KB |
Output is correct |
5 |
Correct |
2 ms |
1748 KB |
Output is correct |
6 |
Incorrect |
0 ms |
1880 KB |
Output isn't correct |
7 |
Correct |
0 ms |
1880 KB |
Output is correct |
8 |
Incorrect |
2 ms |
1880 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
2140 KB |
Output isn't correct |
10 |
Correct |
0 ms |
2152 KB |
Output is correct |
11 |
Correct |
1 ms |
2140 KB |
Output is correct |
12 |
Incorrect |
7 ms |
2152 KB |
Output isn't correct |
13 |
Incorrect |
11 ms |
2152 KB |
Output isn't correct |
14 |
Incorrect |
9 ms |
2140 KB |
Output isn't correct |
15 |
Incorrect |
19 ms |
2140 KB |
Output isn't correct |
16 |
Correct |
0 ms |
2152 KB |
Output is correct |
17 |
Correct |
0 ms |
2152 KB |
Output is correct |
18 |
Correct |
2 ms |
2152 KB |
Output is correct |
19 |
Correct |
4 ms |
2152 KB |
Output is correct |
20 |
Correct |
16 ms |
2152 KB |
Output is correct |