# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115099 | Tsagana | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 2 ms | 504 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(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define sp << ' ' <<
#define nl << '\n'
using namespace std;
double ans[2] = {1e9, 0};
int X[4] = {-1, 1, 0, 0};
int Y[4] = {0, 0, 1, -1};
int change(int x) {
if (x == 'L') return 0;
if (x == 'R') return 1;
if (x == 'F') return 2;
if (x == 'B') return 3;
return 0;
}
double dis(int x, int y) {return sqrt((1.0 * x * x) + (1.0 * y * y));}
void solve () {
int k; cin >> k;
string cmd; cin >> cmd;
int lx, ly, gx, gy;
cin >> lx >> ly >> gx >> gy;
gx -= lx;
gy -= ly;
int x = 0, y = 0;
for (int i = 0; cmd[i]; i++) {
if (cmd[i] == 'I') continue;
int t = change(cmd[i]);
x += X[t];
y += Y[t];
}
for (int i = 0; !i || cmd[i-1]; i++) {
if (cmd[i] == 'I') continue;
int l = 0, r = k-1;
while (l <= r) {
int M = (l + r) / 2;
double b = dis(gx + x * M, gy + y * M);
double c = dis(gx + x * (M+1), gy + y * (M+1));
if (b < c) r = M - 1;
else l = M + 1;
ans[0] = min(ans[0], b);
ans[0] = min(ans[0], c);
}
ans[1] = max(ans[1], dis(gx, gy));
ans[1] = max(ans[1], dis(gx + x * (k-1), gy + y * (k-1)));
int t = change(cmd[i]);
gx += X[t];
gy += Y[t];
}
cout << fixed;
cout << setprecision(10);
cout << ans[0] sp ans[1];
}
signed main() {IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |