#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
double lx,ly,gx,gy,tx,ty;
int n,k;
char s[MAXN];
double dis(double x,double y){
return sqrt((x-lx)*(x-lx)+(y-ly)*(y-ly));
}
double f1(int a){
double x=gx+a*tx;
double y=gy+a*ty;
double res=dis(x,y);
for(int i=0;i<n;i++){
if(s[i]=='L')
x--;
else if(s[i]=='R')
x++;
else if(s[i]=='F')
y++;
else if(s[i]=='B')
y--;
umin(res,dis(x,y));
}return res;
}
double mn(){
int st=0,en=k-1;
while(st+1<en){
int mid=(st+en)>>1;
if(f1(mid)<f1(mid+1))
en=mid;
else
st=mid;
}
return min(f1(st),f1(en));
}
double f2(int a){
double x=gx+a*tx;
double y=gy+a*ty;
double res=dis(x,y);
for(int i=0;i<n;i++){
if(s[i]=='L')
x--;
else if(s[i]=='R')
x++;
else if(s[i]=='F')
y++;
else if(s[i]=='B')
y--;
umax(res,dis(x,y));
}return res;
}
double mx(){
return max(f2(0),f2(k-1));
}
int main(){
//freopen("file.in", "r", stdin);
scanf("%d",&k);
scanf("%s",s);n=strlen(s);
cin>>lx>>ly>>gx>>gy;
for(int i=0;i<n;i++){
if(s[i]=='L')
tx--;
else if(s[i]=='R')
tx++;
else if(s[i]=='F')
ty++;
else if(s[i]=='B')
ty--;
}
printf("%.12lf %.12lf\n",mn(),mx());
return 0;
}
Compilation message
expgorl.cpp: In function 'int main()':
expgorl.cpp:74:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
74 | scanf("%d",&k);
| ~~~~~^~~~~~~~~
expgorl.cpp:75:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
75 | scanf("%s",s);n=strlen(s);
| ~~~~~^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
3 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
3 ms |
364 KB |
Output is correct |
13 |
Correct |
4 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
364 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
4 ms |
364 KB |
Output is correct |