# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894647 | heeheeheehaaw | Experiments with Gorlum (IZhO13_expgorl) | C++17 | 2 ms | 1012 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.
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long double ld;
struct point
{
int x, y;
};
int dist(int x1, int y1, int x2, int y2)
{
return ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2));
}
signed main()
{
int k;
cin>>k;
string s;
cin>>s;
int xl, yl, xs, ys;
cin>>xl>>yl>>xs>>ys;
vector<point> v;
v.push_back({xs, ys});
int x = xs, y = ys;
for(int i = 0; i < s.size(); i++)
{
if(s[i] == 'L')
x--;
if(s[i] == 'R')
x++;
if(s[i] == 'F')
y++;
if(s[i] == 'B')
y--;
v.push_back({x, y});
}
int dx = x - xs;
int dy = y - ys;
int rmax = 0, rmin = 2e18;
for(auto it : v)
{
rmax = max(rmax, dist(it.x, it.y, xl, yl));
rmax = max(rmax, dist(it.x + (k - 1) * dx, it.y + (k - 1) * dy, xl, yl));
int st = 2, dr = k, rez = 1;
while(st <= dr)
{
int mij = (st + dr) / 2;
int d1 = dist(it.x + (mij - 1) * dx, it.y + (mij - 1) * dy, xl, yl);
int d2 = dist(it.x + (mij - 2) * dx, it.y + (mij - 2) * dy, xl, yl);
if(d1 - d2 <= 0) rez = mij, st = mij + 1;
else dr = mij - 1;
}
rmin = min(rmin, dist(it.x + (rez - 1) * dx, it.y + (rez - 1) * dy, xl, yl));
}
cout<<fixed<<setprecision(12);
cout<<(ld)sqrt(rmin)<<" "<<(ld)sqrt(rmax);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |