#include <bits/stdc++.h>
#define ld long double
#define calc() sqrtl((lax-gox)*(lax-gox)+(lay-goy)*(lay-goy))
using namespace std;
ld mini(ld a, ld b){
if(a>b){
return b;
}
return a;
}
ld maxi(ld a, ld b){
if(a>b){
return a;
}
return b;
}
/*
ld calc(ld lax, ld lay, ld gox, ld goy){
return ;
}*/
int main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ld k; string s; cin >> k >> s;
ld lax, lay, gox, goy; cin >> lax >> lay >> gox >> goy;
ld mindis=calc(), maxdis; maxdis=mindis;
ld dis=maxdis;
s="I"+s;
int x[10004], y[10004]; x[0]=lax-gox; y[0]=lay-goy;
//cout << mindis << " " << maxdis;
int n=s.length();
for(int i=1;n>=i;i++){
x[i]=x[i-1]; y[i]=y[i-1];
if(s[i]=='I'){
continue;
}
if(s[i]=='R'){
x[i]++; continue;
}
else if(s[i]=='L'){
x[i]--; continue;
}
else if(s[i]=='F'){
y[i]++; continue;
}
else if(s[i]=='B'){
y[i]--; continue;
}
}
for(int i=0;n>=i;i++){
for(int j=0;k>j;j++){
dis=sqrtl(1LL*(x[i]+j*(x[n]-x[0]))*(x[i]+j*(x[n]-x[0]))+1LL*(y[i]+j*(y[n]-y[0]))*(y[i]+j*(y[n]-y[0])));
mindis=mini(mindis, dis); maxdis=maxi(maxdis, dis);
}
}
cout << setprecision(12) << fixed << mindis << " " << maxdis;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
255 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |