답안 #47543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47543 2018-05-05T03:15:37 Z kuroni 생물 실험 (IZhO13_expgorl) C++14
컴파일 오류
0 ms 0 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()
{
    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 = 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:46:17: error: 'ma' was not declared in this scope
     double mi = ma = dist(g[0], 0);
                 ^~
expgorl.cpp:46:17: note: suggested alternative: 'mi'
     double mi = ma = dist(g[0], 0);
                 ^~
                 mi
expgorl.cpp:44: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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~