Submission #97163

# Submission time Handle Problem Language Result Execution time Memory
97163 2019-02-14T08:11:13 Z Kastanda Experiments with Gorlum (IZhO13_expgorl) C++11
0 / 100
3 ms 384 KB
// I do it for the glory
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 14004;
int n, k, Lx, Ly, Gx, Gy;
vector < pair < int , int > > A;
char S[N];
inline ll Dist(ll a, ll b)
{
    return ((Lx - a) * (Lx - a) + (Ly - b) * (Ly - b));
}
int main()
{
    scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy);
    n = strlen(S);
    ll nwx = Gx, nwy = Gy;
    A.pb({nwx, nwy});
    for (int i = 0; i < n; i++)
    {
        if (S[i] == 'L') nwx --;
        if (S[i] == 'R') nwx ++;
        if (S[i] == 'F') nwy ++;
        if (S[i] == 'B') nwy --;
        if (S[i] == 'I') continue;
        A.pb({nwx, nwy});
    }
    ll dfx = nwx - Gx, dfy = nwy - Gy;
    ll Mn = 4e18, Mx = - Mn;
    for (int i = 0; i < (int)A.size(); i++)
    {
        tie(nwx, nwy) = A[i];
        Mx = max(Mx, Dist(nwx, nwy));
        Mx = max(Mx, Dist(nwx + dfx * k, nwy + dfy * k));
        int le = 0, ri = k, md1, md2;
        while (ri - le > 3)
        {
            md1 = (le + le + ri) / 3;
            md2 = (le + ri + ri) / 3;
            ll d1 = Dist(nwx + dfx * md1, nwy + dfy * md1);
            ll d2 = Dist(nwx + dfx * md2, nwy + dfy * md2);
            if (d1 < d2) ri = md2;
            else le = md1;
        }
        for (; le <= ri; le ++)
            Mn = min(Mn, Dist(nwx + dfx * le, nwy + dfy * le));
    }
    cout << fixed << setprecision(15);
    cout << sqrt(Mn) << " " << sqrt(Mx) << endl;
    return 0;
}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:18:53: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'char (*)[14004]' [-Wformat=]
     scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy);
                               ~~                    ^
expgorl.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -