# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92652 | SamAnd | Experiments with Gorlum (IZhO13_expgorl) | C++17 | 3 ms | 508 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 <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int N=100005;
struct ban
{
long long x,y;
};
long double her(const ban& a,const ban& b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+0.0);
}
int k,n;
char a[N];
ban laser,s,g;
long double minu=10000000000007,maxu;
void ubd(ban t)
{
long double h=her(laser,t);
if(h<minu)
minu=h;
if(h>maxu)
maxu=h;
}
void stg(int ki)
{
ban t;
t.x=s.x+g.x*ki;
t.y=s.y+g.y*ki;
ubd(t);
for(int i=0;i<n;++i)
{
if(a[i]=='L')
t.x--;
if(a[i]=='R')
t.x++;
if(a[i]=='F')
t.y++;
if(a[i]=='B')
t.y--;
ubd(t);
}
}
int main()
{
//freopen("expgorl.in","r",stdin);
//freopen("expgorl.out","w",stdout);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(12);
//////////////////////////
cin>>k;
cin>>a;
n=strlen(a);
cin>>laser.x>>laser.y;
cin>>s.x>>s.y;
for(int i=0;i<n;++i)
{
if(a[i]=='L')
g.x--;
if(a[i]=='R')
g.x++;
if(a[i]=='F')
g.y++;
if(a[i]=='B')
g.y--;
}
//////////////////////////
stg(0);
if(k!=1)
stg(1);
if(k!=1)
stg(k-2);
stg(k-1);
long double h=her(laser,s);
ban t=s;
for(int i=0;i<k;++i)
{
t.x+=g.x;
t.y+=g.y;
long double hh=her(laser,t);
if(h<=hh)
{
if(i!=0)
stg(i-1);
if(i-2>=0)
stg(i-2);
stg(i);
if(i!=(k-1))
stg(i+1);
break;
}
h=hh;
}
//////////////////////////
cout<<minu<<' '<<maxu<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |