# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
477216 | ogibogi2004 | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 1 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define y1 fddsfdsd
const ld INF=2e10;
int k;
string s;
struct point
{
ld x,y;
};
vector<point>v;
ld x1,y1,xa,ya;
ld mindist=INF,maxdist=-INF;
ld calcdist(point p1,ld t)
{
ld xx=p1.x+t*xa;
ld yy=p1.y+t*ya;
return sqrt(xx*xx+yy*yy);
}
ld ts(point p)
{
int l=0,r=k-1,m1,m2;
while(r-l>2)
{
m1=l+(r-l)/3;
m2=l+2*(r-l)/3;
if(calcdist(p,m1)>=calcdist(p,m2))
{
l=m1+1;
}
else r=m2-1;
}
ld ret=INF;
for(int i=l;i<=r;i++)
{
ret=min(ret,calcdist(p,i));
}
return ret;
}
int main()
{
cin>>k;
cin>>s;
int xl,yl,xg,yg;
cin>>xl>>yl;
cin>>xg>>yg;
x1=xg-xl;y1=yg-yl;
v.push_back({x1,y1});
for(int i=0;i<s.size();i++)
{
if(s[i]=='R')x1++;
if(s[i]=='L')x1--;
if(s[i]=='F')y1++;
if(s[i]=='B')y1--;
v.push_back({x1,y1});
}
xa=x1;ya=y1;
//cout<<xa<<" "<<ya<<endl;
for(int i=0;i<v.size();i++)
{
//cout<<v[i].x<<" "<<v[i].y<<endl;
mindist=min(mindist,ts(v[i]));
maxdist=max(maxdist,calcdist(v[i],0));
maxdist=max(maxdist,calcdist(v[i],k-1));
//cout<<calcdist(v[i],0)<<" "<<calcdist(v[i],k-1)<<endl;
//cout<<maxdist<<endl;
}
cout<<fixed<<setprecision(11)<<mindist<<" "<<maxdist<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |