답안 #92652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92652 2019-01-04T09:32:19 Z SamAnd 생물 실험 (IZhO13_expgorl) C++17
100 / 100
3 ms 508 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 396 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct