Submission #165053

#TimeUsernameProblemLanguageResultExecution timeMemory
165053aZvezdaExperiments with Gorlum (IZhO13_expgorl)C++11
0 / 100
194 ms508 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" #define pb push_back typedef long long ll; typedef long double ld; typedef unsigned long long ull; const ll mod = 1e9 + 7; ld sX, sY; ld gX, gY; ld dX, dY; int k; string s; pair<ld, ld> eval(int q) { ld mn = 2 * mod, mx = -1; ld cX = gX + dX * (q - 1), cY = gY + dY * (q - 1); for(auto it : s) { ld curr = sqrt((sX - cX) * (sX - cX) + (sY - cY) * (sY - cY)); mn = min(mn, curr); mx = max(mx, curr); if(it == 'L') { cX ++; } else if(it == 'R') { cX --; } else if(it == 'F') { cY ++; } else if(it == 'B') { cY --; } } return {mn, mx}; } int main() { //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> k >> s; s.push_back('I'); cin >> sX >> sY; cin >> gX >> gY; for(auto it : s) { if(it == 'L') { dX ++; } else if(it == 'R') { dX --; } else if(it == 'F') { dY ++; } else if(it == 'B') { dY --; } } ld mn = 2 * mod, mx = -1; for(int i = 1; i <= k; i ++) { auto curr = eval(i); mn = min(mn, curr.first); mx = max(mn, curr.second); } cout << fixed << setprecision(12); cout << mn << " " << mx << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...