# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84449 | farukkastamonuda | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 2 ms | 376 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 <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
double k,lx,ly,gx,gy;
char s[li];
double mx,mn=inf,lst,lst2;
double abs1(double a){
if(a<=0) return -a;
return a;
}
double dis(double a,double b){
double aa=a,bb=b;
double cc=lx,dd=ly;
return sqrt(abs1(aa-cc)*abs1(aa-cc)+abs1(bb-dd)*abs1(bb-dd));
}
int main(){
scanf("%lf",&k);
scanf("%s",s+1);
int t=strlen(s+1);
scanf("%lf %lf %lf %lf",&lx,&ly,&gx,&gy);
mx=max(mx,dis(gx,gy));
mn=min(mn,dis(gx,gy));
//if(k<=20000 && t<=2000){
for(int i=1;i<=k;i++){
lst=mx;
lst2=mn;
for(int j=1;j<=t;j++){
if(s[j]=='L'){
gx--;
}
if(s[j]=='R'){
gx++;
}
if(s[j]=='F'){
gy++;
}
if(s[j]=='B'){
gy--;
}
mx=max(mx,dis(gx,gy));
mn=min(mn,dis(gx,gy));
}
if(mx>lst && i>1){
mx+=(k-1)*(mx-lst);
}
if(mn<lst2 && i>1){
mn-=(k-1)*(lst2-mn);
}
if(i>1) break;
}
printf("%lf\n%lf\n",mn,mx);
//}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |