답안 #339311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339311 2020-12-25T03:52:53 Z beksultan04 생물 실험 (IZhO13_expgorl) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-15
const int N = 1e5+12,INF=1e9+7;

long double disting(long double x,long double y,long double x1,long double y1){
    ret ((x-x1)*(x-x1))+((y-y1)*(y-y1));
}

main(){
    long double k,i,j,x1,y1,l=0,r=0,x,y,mn,mx,mnll=INF,mnrl=INF,mxll=-INF,mxrl=-INF,mnlr=INF,mnrr=INF,mxlr=-INF,mxrr=-INF;
    string s,t="";
    cin>>k>>s>>x>>y>>x1>>y1;
    t = s;
    cout <<fixed <<setprecision(12);
    mn = disting(x,y,x1,y1);
    mx = disting(x,y,x1,y1);

    for (i=0;i<s.size();++i){
        if (s[i] == 'L'){
            l--;
        }
        if (s[i] == 'R'){
            l++;
        }
        if (s[i] == 'F'){
            r++;
        }
        if (s[i] == 'B'){
            r--;
        }
        if (mnll >  l){
            mnll = l;
            mnlr = r;
        }
        if (mnrr > r){
            mnrl = l;
            mnrr = r;
        }
        if (mxll < l){
            mxll = l;
            mxlr = r;
        }
        if (mxrr > r){
            mxrr = r;
            mxrl = l;
        }
        mn = min(mn,disting(x,y,x1+l,y1+r));
        mx = max(mx,disting(x,y,x1+l,y1+r));
    }
    {
        int yl = l*(k-1);
        int yr = r*(k-1);

        for (i=0;i<s.size();++i){
            if (s[i] == 'L'){
                yl--;
            }
            if (s[i] == 'R'){
                yl++;
            }
            if (s[i] == 'F'){
                yr++;
            }
            if (s[i] == 'B'){
                yr--;
            }
            mx = max(mx,disting(x,y,x1+yl,y1+yr));
        }
    }
    while (k--){

        mn = min(mn,disting(x,y,x1+l,y1+r));
        mn = min(mn,disting(x,y,x1+mnll,y1+mnlr));
        mn = min(mn,disting(x,y,x1+mnrl,y1+mnrr));
        x1+=l;
        y1+=r;

    }


    cout <<sqrt(mn)<<" "<<sqrt(mx);
}






Compilation message

expgorl.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      |      ^
expgorl.cpp: In function 'int main()':
expgorl.cpp:27:21: warning: unused variable 'j' [-Wunused-variable]
   27 |     long double k,i,j,x1,y1,l=0,r=0,x,y,mn,mx,mnll=INF,mnrl=INF,mxll=-INF,mxrl=-INF,mnlr=INF,mnrr=INF,mxlr=-INF,mxrr=-INF;
      |                     ^
expgorl.cpp:27:75: warning: variable 'mxrl' set but not used [-Wunused-but-set-variable]
   27 |     long double k,i,j,x1,y1,l=0,r=0,x,y,mn,mx,mnll=INF,mnrl=INF,mxll=-INF,mxrl=-INF,mnlr=INF,mnrr=INF,mxlr=-INF,mxrr=-INF;
      |                                                                           ^~~~
expgorl.cpp:27:103: warning: variable 'mxlr' set but not used [-Wunused-but-set-variable]
   27 |     long double k,i,j,x1,y1,l=0,r=0,x,y,mn,mx,mnll=INF,mnrl=INF,mxll=-INF,mxrl=-INF,mnlr=INF,mnrr=INF,mxlr=-INF,mxrr=-INF;
      |                                                                                                       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -