# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97162 | 2019-02-14T08:10:19 Z | Kastanda | Experiments with Gorlum (IZhO13_expgorl) | C++11 | 1 ms | 512 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 < ll , ll > > 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(12); cout << sqrt(Mn) << " " << sqrt(Mx); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |