제출 #165054

#제출 시각아이디문제언어결과실행 시간메모리
165054aZvezdaExperiments with Gorlum (IZhO13_expgorl)C++14
0 / 100
158 ms376 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) - sX, cY = gY + dY * (q - 1) - sY; for(auto it : s) { ld curr = sqrt(cX * cX + cY * 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...