# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009059 | ivopav | Experiments with Gorlum (IZhO13_expgorl) | C++17 | 2 ms | 348 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;
long long int dist(long long int x1,long long int y1,long long int x2,long long int y2){
// cout << x1 << ' ' << y1 << " " << x2 << " " << y2 << "\n";
// cout << abs(x1-x2) << " " << abs(x1-x2)*abs(x1-x2) << " " << abs(y1-y2)*abs(y1-y2) << " " << abs(y1-y2) << "\n";
return abs(x1-x2)*abs(x1-x2)+abs(y1-y2)*abs(y1-y2);
}
int main(){
long long int k;
string str;
long long int lsrx;
long long int lsry;
long long int grmx;
long long int grmy;
cin >> k >> str >> lsrx >> lsry >> grmx >> grmy;
long long int x=0;
long long int y=0;
str+='I';
long long int n=str.size();
for (long long int i=0;i<n;i++){
if (str[i]=='L'){
x--;
}
if (str[i]=='R'){
x++;
}
if (str[i]=='F'){
y++;
}
if (str[i]=='B'){
y--;
}
}
long long int najm=2e9+100;
long long int najv=0;
for (long long int i=0;i<n;i++){
long long int l=0;
long long int r=k-1;
long long int mid=k/2;
while (l<r){
long long int mid2=mid+1;
long long int sadxmid=grmx+x*mid;
long long int sadymid=grmy+y*mid;
long long int sadxmid2=grmx+x*mid2;
long long int sadymid2=grmy+y*mid2;
long long int distmid=dist(sadxmid,sadymid,lsrx,lsry);
long long int distmid2=dist(sadxmid2,sadymid2,lsrx,lsry);
if (distmid<distmid2){
r=mid;
}
else {
l=mid2;
}
mid=(l+r)/2;
}
//cout << grmx+x*k-x << " " << grmy+y*k-y << " " << lsrx << " " << lsry << "\n";
//cout << dist(grmx+x*k-x,grmy+y*k-y,lsrx,lsry) << "\n";
najm=min(najm,dist(grmx+x*mid,grmy+y*mid,lsrx,lsry));
najv=max(najv,dist(grmx,grmy,lsrx,lsry));
najv=max(najv,dist(grmx+x*k-x,grmy+y*k-y,lsrx,lsry));
if (str[i]=='L'){
grmx--;
}
if (str[i]=='R'){
grmx++;
}
if (str[i]=='F'){
grmy++;
}
if (str[i]=='B'){
grmy--;
}
}
cout << setprecision(200) << sqrt(najm) << " " << sqrt(najv) << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |