# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165054 | aZvezda | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 158 ms | 376 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>
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |