# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
107875 | SamAnd | 생물 실험 (IZhO13_expgorl) | C++17 | 5 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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()
{
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... |