#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define change(x) ((x)!='L'?(x)!='R'?(x)!='F'?3:2:1:0)
char ch[10010];
int K,sx,sy;
double ans[2] = {1e9+1e5,0};
int xx[4] = {-1,1,0,0}, yy[4] = {0,0,1,-1};
int itx,ity;
inline double dis(int x,int y){return sqrt(1.*x*x+1.*y*y);}
int main(){
scanf("%d %s",&K,ch);
int x,y;
scanf("%d%d%d%d",&x,&y,&sx,&sy);
sx-=x,sy-=y;
for(int i=0;ch[i];i++){
if(ch[i] == 'I')continue;
int tmp = change(ch[i]);
itx += xx[tmp], ity += yy[tmp];
}
for(int i=0;!i||ch[i-1];i++){
if(ch[i] == 'I')continue;
int st = 0, en = K-1, a, b;
while(st<=en){
a = (st+en)>>1;
double b = dis(sx + itx * a, sy + ity * a);
double c = dis(sx + itx * (a+1), sy + ity * (a+1));
if(b<c)en = a-1;
else st = a+1;
ans[0] = min(ans[0], b);
ans[0] = min(ans[0], c);
}
ans[1] = max(ans[1],dis(sx,sy));
ans[1] = max(ans[1],dis(sx + itx * (K-1), sy + ity * (K-1)));
int tmp = change(ch[i]);
sx += xx[tmp], sy += yy[tmp];
}
printf("%.10f %.10f",ans[0],ans[1]);
return 0;
}
Compilation message
expgorl.cpp: In function 'int main()':
expgorl.cpp:29:28: warning: unused variable 'b' [-Wunused-variable]
int st = 0, en = K-1, a, b;
^
expgorl.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %s",&K,ch);
~~~~~^~~~~~~~~~~~~~~
expgorl.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d",&x,&y,&sx,&sy);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
256 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
4 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |