# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17508 | azecoder | Experiments with Gorlum (IZhO13_expgorl) | C++98 | 19 ms | 2152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 , t[100] ;
long double sx , sy , gx , gy , fx , fy , mn , 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 * fx ;
y += k * 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 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |