Submission #862888

# Submission time Handle Problem Language Result Execution time Memory
862888 2023-10-19T09:01:18 Z Darren0724 Experiments with Gorlum (IZhO13_expgorl) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int m;cin>>m;m--;
    string s;cin>>s;
    int n=s.size();
    int a,b,c,d;cin>>a>>b>>c>>d;
    int e=0,f=0;
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            e--;
        }
        if(s[i]=='R'){
            e++;
        }
        if(s[i]=='F'){
            f++;
        }
        if(s[i]=='B'){
            f--;
        }
    }
    long double mn=1e18,mx=0;
    auto cal=[&](int a,int b)->long double {
        return sqrtl(a*a+b*b);
    };
    {   mx=max(mx,cal(c-a,d-b));
        mx=max(mx,cal(c+m*e-a,d+m*f-b));
        int l=0,r=m;
        while(r-l>1){
            int mi=(l+r)>>1;
            if(cal(c+mi*e-a,d+mi*f-b)>=cal(c+(mi+1)*e-a,d+(mi+1)*f-b)){
                l=mi;
            }
            else{
                r=mi;
            }
        }
        //cout<<c+l*e-a<<' '<<d+l*f-b<<endl;
        mn=min(mn,cal(c+l*e-a,d+l*f-b));
    }
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            c--;
        }
        if(s[i]=='R'){
            c++;
        }
        if(s[i]=='F'){
            d++;
        }
        if(s[i]=='B'){
            d--;
        }
        mx=max(mx,cal(c-a,d-b));
        mx=max(mx,cal(c+m*e-a,d+m*f-b));
        int l=0,r=m;
        while(r-l>1){
            int mi=(l+r)>>1;
            if(cal(c+mi*e-a,d+mi*f-b)>=cal(c+(mi+1)*e-a,d+(mi+1)*f-b)){
                l=mi;
            }
            else{
                r=mi;
            }
        }
        mn=min(mn,cal(c+l*e-a,d+l*f-b));
    }
    cout<<fixed<<setprecision(10)<<mn<<' '<<mx<<endl;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -