# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4808 | cki86201 | Experiments with Gorlum (IZhO13_expgorl) | C++98 | 4 ms | 1108 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<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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |