답안 #47544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47544 2018-05-05T03:16:31 Z kuroni 생물 실험 (IZhO13_expgorl) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int N = 10005;
const double INF = 1E18 + 7;

struct SPoint
{
    long long x, y;
} g[N], o;
int k, n;
long long dx, dy;
char s[N];

double dist(const SPoint &a, int iter)
{
    return hypot(dx * iter + a.x - o.x, dy * iter + a.y - o.y);
}

double TS(const SPoint &a)
{
    double ret = INF;
    int l = 0, r = k - 1;
    while (r - l >= 3)
    {
        int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
        double d1 = dist(a, m1), d2 = dist(a, m2);
        ret = min(ret, min(d1, d2));
        if (d1 > d2)
            l = m1;
        else
            r = m2;
    }
    for (; l <= r; l++)
        ret = min(ret, dist(a, l));
    return ret;
}

int main()
{
    freopen("expgorl.inp", "r", stdin);
    freopen("expgorl.out", "w", stdout);
    scanf("%d\n%s\n%lld %lld\n%lld %lld", &k, s + 1, &g[0].x, &g[0].y, &o.x, &o.y);
    n = strlen(s + 1);
    double mi = dist(g[0], 0), ma = dist(g[0], 0);
    for (int i = 1; i <= n; i++)
        switch (s[i])
        {
            case 'L':
                g[i] = (SPoint){g[i - 1].x - 1, g[i - 1].y};
                break;
            case 'R':
                g[i] = (SPoint){g[i - 1].x + 1, g[i - 1].y};
                break;
            case 'F':
                g[i] = (SPoint){g[i - 1].x, g[i - 1].y + 1};
                break;
            case 'B':
                g[i] = (SPoint){g[i - 1].x, g[i - 1].y - 1};
                break;
            case 'I':
                g[i] = (SPoint){g[i - 1].x, g[i - 1].y};
                break;
        }
    dx = g[n].x - g[0].x; dy = g[n].y - g[0].y;
    for (int i = 1; i <= n; i++)
    {
        ma = max(ma, max(dist(g[i], 0), dist(g[i], k - 1)));
        mi = min(mi, TS(g[i]));
    }
    printf("%.16f %.16f\n", mi, ma);
}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("expgorl.inp", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
expgorl.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("expgorl.out", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
expgorl.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d\n%s\n%lld %lld\n%lld %lld", &k, s + 1, &g[0].x, &g[0].y, &o.x, &o.y);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -