답안 #477219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477219 2021-10-01T06:13:26 Z ogibogi2004 생물 실험 (IZhO13_expgorl) C++14
0 / 100
272 ms 372 KB
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define y1 fddsfdsd
const ld INF=2e15;
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;
    ld mindist1=INF,maxdist1=-INF;
    //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));
        for(int j=0;j<k;j++)
        {
            mindist1=min(mindist1,calcdist(v[i],j));
            maxdist1=max(maxdist1,calcdist(v[i],j));
        }
        //cout<<calcdist(v[i],0)<<" "<<calcdist(v[i],k-1)<<endl;
        //cout<<maxdist<<endl;
    }
    //cout<<fixed<<setprecision(11)<<mindist<<" "<<maxdist<<endl;
    cout<<fixed<<setprecision(11)<<mindist1<<" "<<maxdist1<<endl;
return 0;
}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
expgorl.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 272 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -