Submission #4808

#TimeUsernameProblemLanguageResultExecution timeMemory
4808cki86201Experiments with Gorlum (IZhO13_expgorl)C++98
100 / 100
4 ms1108 KiB
#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 timeMemoryGrader output
Fetching results...