#include <cstdio>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long lint;
typedef pair<lint,lint> pi;
int k;
char s[10005];
pi afterCycle, a[10005], laser, ainta, mp[150];
lint minv, maxv;
lint dist(pi x, pi y){
return (y.second - x.second)*(y.second - x.second) + (y.first - x.first)*(y.first - x.first);
}
pi mv(pi x, int time){
return pi(x.first + afterCycle.first * time, x.second + afterCycle.second * time);
}
void input(){
scanf("%d %s",&k,s);
scanf("%lld %lld %lld %lld",&laser.first,&laser.second,&ainta.first,&ainta.second);
mp['I'] = pi(0ll,0ll);
mp['L'] = pi(-1ll,0ll);
mp['R'] = pi(1ll,0ll);
mp['B'] = pi(0ll,-1ll);
mp['F'] = pi(0ll,1ll);
}
int main(){
input();
minv = maxv = dist(laser,ainta);
pi x = ainta;
for (int i=0; s[i]; i++) {
x.first += mp[s[i]].first;
x.second += mp[s[i]].second;
a[i] = x;
}
afterCycle = pi(x.first - ainta.first,x.second - ainta.second);
for (int i=0; s[i]; i++) {
for (int j=0; j<k; j++) {
minv = min(minv,dist(laser,mv(a[i],j)));
maxv = max(maxv,dist(laser,mv(a[i],j)));
}
}
printf("%lf\n%lf",sqrt(minv),sqrt(maxv));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
1268 KB |
Output is correct |
2 |
Correct |
68 ms |
1268 KB |
Output is correct |
3 |
Correct |
76 ms |
1268 KB |
Output is correct |
4 |
Correct |
80 ms |
1268 KB |
Output is correct |
5 |
Correct |
40 ms |
1268 KB |
Output is correct |
6 |
Correct |
60 ms |
1268 KB |
Output is correct |
7 |
Correct |
64 ms |
1268 KB |
Output is correct |
8 |
Correct |
92 ms |
1268 KB |
Output is correct |
9 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
10 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
11 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
12 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
13 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
14 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
15 |
Execution timed out |
1000 ms |
1268 KB |
Program timed out |
16 |
Execution timed out |
1000 ms |
1264 KB |
Program timed out |
17 |
Execution timed out |
1000 ms |
1264 KB |
Program timed out |
18 |
Execution timed out |
1000 ms |
1264 KB |
Program timed out |
19 |
Execution timed out |
1000 ms |
1264 KB |
Program timed out |
20 |
Execution timed out |
1000 ms |
1264 KB |
Program timed out |