# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
521480 | Kalashnikov | Experiments with Gorlum (IZhO13_expgorl) | C++17 | 14 ms | 356 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 ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const int N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
long double mn = INF , mx = -INF;
long double lx , ly;
long double gx , gy;
long double cx , cy;
long double calc(long double gx , long double gy) {
long double A = lx-gx;
long double B = ly-gy;
long double res = sqrt(A*A + B*B);
return res;
}
void solve(int tc) {
int k;
string s;
cin >> k;
cin >> s;
cin >> lx >> ly >> gx >> gy;
for(auto to: s) {
if(to == 'L') cx --;
if(to == 'R') cx ++;
if(to == 'F') cy ++;
if(to == 'B') cy --;
}
long double curx = 0, cury = 0;
for(auto to: s) {
if(to == 'L') curx --;
if(to == 'R') curx ++;
if(to == 'F') cury ++;
if(to == 'B') cury --;
int l = 0 , r = k-1;
while(l <= r) {
int m1 = l + (r-l)/3;
int m2 = r - (r-l)/3;
long double g1x = gx + cx*m1 + curx , g1y = gy + cy*m1 + cury;
long double g2x = gx + cx*m2 + curx , g2y = gy + cy*m2 + cury;
mn = min(mn , calc(g1x, g1y));
mn = min(mn , calc(g2x, g2y));
if(calc(g1x, g1y) < calc(g2x , g2y)) {
r = m2-1;
}
else {
l = m1+1;
}
}
mx = max(mx , calc(gx + curx , gy + cury));
mx = max(mx , calc(gx + curx + (k-1)*cx, gy + cury + (k-1)*cy));
}
cout << fixed << setprecision(17) << mn << ' ' << mx;
}
/*
*/
main() {
ios;
int tt = 1 , tc = 0;
// cin >> tt;
while(tt --) {
solve(++tc);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |