# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676565 | QwertyPi | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 2 ms | 724 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;
struct point{
int x, y;
};
int dx[256], dy[256];
int dis(point A, point B){
return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
}
long long low = 1LL << 60, high = -(1LL << 60);
point L, G, D;
void check(point X){
int d = dis(X, D);
low = min(low, d);
high = max(high, d);
}
int K;
int lim(int x){
return max(min(x, K - 1), 0LL);
}
int32_t main(){
cin >> K;
string s; cin >> s;
dx['L'] = -1; dy['L'] = 0;
dx['R'] = 1; dy['R'] = 0;
dx['F'] = 0; dy['F'] = 1;
dx['B'] = 0; dy['B'] = -1;
dx['I'] = 0; dy['I'] = 0;
int x, y; cin >> x >> y; L = {x, y}; cin >> x >> y; G = {x, y};
D = {L.x - G.x, L.y - G.y};
point X {0, 0};
vector<point> pts;
for(auto c : s){
pts.push_back(X);
X.x += dx[c]; X.y += dy[c];
}
int cx = X.x, cy = X.y;
check({cx * K, cy * K});
for(auto p : pts){
check(p); check({p.x + cx * (K - 1), p.y + cy * (K - 1)});
}
if(cx * cx + cy * cy != 0){
for(auto p : pts){
int a = cx * cx + cy * cy, b = -2LL * ((D.x - p.x) * cx + (D.y - p.y) * cy), c = (D.x - p.x) * (D.x - p.x) + (D.y - p.y) * (D.y - p.y);
int opt = -b / a / 2;
auto check_2 = [&p, &cx, &cy](int x){
check({p.x + lim(x) * cx, p.y + lim(x) * cy});
};
check_2(opt - 1); check_2(opt); check_2(opt + 1);
}
}
cout << fixed << setprecision(12) << sqrt(low) << ' ' << sqrt(high) << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |