# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97165 | Kastanda | Experiments with Gorlum (IZhO13_expgorl) | C++11 | 7 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |