# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97165 | 2019-02-14T08:16:24 Z | Kastanda | Experiments with Gorlum (IZhO13_expgorl) | C++11 | 7 ms | 640 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 = 7e18, 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 - 1), nwy + dfy * (k - 1))); int le = 0, ri = k - 1, 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((long double)Mn) << " " << sqrt((long double)Mx) << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 640 KB | Output is correct |
10 | Correct | 4 ms | 640 KB | Output is correct |
11 | Correct | 4 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
14 | Correct | 7 ms | 640 KB | Output is correct |
15 | Correct | 3 ms | 640 KB | Output is correct |
16 | Correct | 3 ms | 640 KB | Output is correct |
17 | Correct | 3 ms | 640 KB | Output is correct |
18 | Correct | 5 ms | 640 KB | Output is correct |
19 | Correct | 5 ms | 640 KB | Output is correct |
20 | Correct | 5 ms | 640 KB | Output is correct |