# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168907 | abil | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 339 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 fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);
int lx, ly;
double ansmin, ansmax;
double dist(double x, double y){
return sqrt((x - lx) * (x - lx) + (y - ly) * (y - ly));
}
string s;
double gx, gy, x = 0, y = 0;
void check(int val){
double gxx = gx + val * x, gyy = gy + val * y;
ansmin = min(ansmin, dist(gxx, gyy));
ansmax = max(ansmax, dist(gxx, gyy));
for(int i = 0;i < s.size(); i++){
if(s[i] == 'L'){
gxx--;
}
if(s[i] == 'R'){
gxx++;
}
if(s[i] == 'F'){
gyy++;
}
if(s[i] == 'B'){
gyy--;
}
ansmin = min(ansmin, dist(gxx, gyy));
ansmax = max(ansmax, dist(gxx, gyy));
}
}
main()
{
int k;
scanf("%d", &k);
cin >> s;
cin >> lx >> ly;
cin >> gx >> gy;
ansmin = dist(gx, gy), ansmax = dist(gx, gy);
for(int i = 0;i < s.size(); i++){
if(s[i] == 'L'){
x--;
}
if(s[i] == 'R'){
x++;
}
if(s[i] == 'F'){
y++;
}
if(s[i] == 'B'){
y--;
}
}
for(int i = 0;i <= min(k - 1, 1000); i++){
check(i);
}
for(int i = max(1001, k - 1000);i <= k - 1; i++){
check(i);
}
cout << fixed << setprecision(9) << ansmin << " " << ansmax;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |