# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009452 | bornag | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 2 ms | 600 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;
#define ll long long
#define ld long double
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll tx, ty, lx, ly, gx, gy, k, si;
string s;
ld calc(ll xi, ll yi, ll xxi, ll yyi){
return abs(xi-xxi)*abs(xi-xxi)+abs(yi-yyi)*abs(yi-yyi);
}
int main(){
cin >> k >> s;
cout << fixed << setprecision(12);
si = s.size();
for(auto x : s){
if(x == 'L') tx--;
else if(x == 'R') tx++;
else if(x == 'F') ty++;
else if(x == 'B') ty--;
}
cin >> lx >> ly >> gx >> gy;
ld mni = calc(gx, gy, lx, ly);
ld mxi = max(calc(gx, gy, lx, ly), calc(lx, ly, gx+tx*(k-1), gy+ty*(k-1)));
for(int i = 0; i < si; i++){
ll lo = 0;
ll hi = k-1; // jer provjeravam i mid+1
ll mid = (lo+hi)/2;
while(lo < hi){
mid = (lo+hi)/2;
ld xc = gx + tx*mid; //nakon mid*s
ld yc = gy + ty*mid; //nakon mid*s
ld xd = gx + tx*(mid+1); //jos jedan dalje
ld yd = gy + ty*(mid+1);
if(calc(lx, ly, xc, yc) < calc(lx, ly, xd, yd)){
hi = mid;
} else {
lo = mid+1;
}
}
mid = (lo+hi)/2;
mxi = max(mxi, max(calc(gx, gy, lx, ly), calc(lx, ly, gx+tx*(k-1), gy+ty*(k-1))));
mni = min(mni, calc(lx, ly, gx + tx*mid, gy+ty*mid));
char so = s[i];
if(so == 'L') gx--;
else if(so == 'R') gx++;
else if(so == 'F') gy++;
else if(so == 'B') gy--;
}
cout << sqrt(mni) << ' ' << sqrt(mxi);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |