Submission #1115099

#TimeUsernameProblemLanguageResultExecution timeMemory
1115099TsaganaExperiments with Gorlum (IZhO13_expgorl)C++14
100 / 100
2 ms504 KiB
#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 timeMemoryGrader output
Fetching results...