Submission #8102

# Submission time Handle Problem Language Result Execution time Memory
8102 2014-08-30T01:03:16 Z baneling100 Experiments with Gorlum (IZhO13_expgorl) C++
5 / 100
4 ms 1188 KB
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define INF 0x7fffffff

using namespace std;

int K, Len, Lx, Ly, Ax, Ay, Vx, Vy, Sx[10001], Sy[10001], MAX, MIN=INF;
char S[10002];

void input(void) {

    scanf("%d %s %d %d %d %d",&K,&S[1],&Lx,&Ly,&Ax,&Ay);
    Len=strlen(&S[1]);
}

pair <int,int> Order(char T) {

    if(T=='L') return make_pair(-1,0);
    else if(T=='R') return make_pair(1,0);
    else if(T=='F') return make_pair(0,1);
    else if(T=='B') return make_pair(0,-1);
    return make_pair(0,0);
}

void process(void) {

    pair <int,int> Temp;
    int Ex, Ey, Left, Mid1, Mid2, Right, D1, D2;

    Sx[0]=Ax;
    Sy[0]=Ay;
    for(int i=1 ; i<=Len ; i++) {
        Temp=Order(S[i]);
        Sx[i]=Sx[i-1]+Temp.first;
        Sy[i]=Sy[i-1]+Temp.second;
    }
    Vx=Sx[Len]-Ax;
    Vy=Sy[Len]-Ay;
    for(int i=0 ; i<=Len ; i++) {
        Ex=Sx[i]+Vx*(K-1);
        Ey=Sy[i]+Vy*(K-1);
        MAX=max(MAX,max((Sx[i]-Lx)*(Sx[i]-Lx)+(Sy[i]-Ly)*(Sy[i]-Ly),(Ex-Lx)*(Ex-Lx)+(Ey-Ly)*(Ey-Ly)));
        Left=0;
        Right=K-1;
        while(Right-Left>=2) {
            Mid1=(2*Left+Right)/3;
            Mid2=(Left+2*Right)/3;
            Ex=Sx[i]+Vx*Mid1;
            Ey=Sy[i]+Vy*Mid1;
            D1=(Ex-Lx)*(Ex-Lx)+(Ey-Ly)*(Ey-Ly);
            Ex=Sx[i]+Vx*Mid2;
            Ey=Sy[i]+Vy*Mid2;
            D2=(Ex-Lx)*(Ex-Lx)+(Ey-Ly)*(Ey-Ly);
            if(D1<D2)
                Right=Mid2-1;
            else
                Left=Mid1+1;
        }
        Ex=Sx[i]+Vx*Left;
        Ey=Sy[i]+Vy*Left;
        D1=(Ex-Lx)*(Ex-Lx)+(Ey-Ly)*(Ey-Ly);
        Ex=Sx[i]+Vx*Right;
        Ey=Sy[i]+Vy*Right;
        D2=(Ex-Lx)*(Ex-Lx)+(Ey-Ly)*(Ey-Ly);
        MIN=min(MIN,min(D1,D2));
    }
}

void output(void) {

    printf("%.15lf %.15lf",sqrt(MIN),sqrt(MAX));
}

int main(void) {

    input();
    process();
    output();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1188 KB Output isn't correct
2 Incorrect 0 ms 1188 KB Output isn't correct
3 Incorrect 0 ms 1188 KB Output isn't correct
4 Incorrect 0 ms 1188 KB Output isn't correct
5 Incorrect 0 ms 1188 KB Output isn't correct
6 Incorrect 0 ms 1188 KB Output isn't correct
7 Incorrect 0 ms 1188 KB Output isn't correct
8 Incorrect 0 ms 1188 KB Output isn't correct
9 Incorrect 0 ms 1188 KB Output isn't correct
10 Incorrect 0 ms 1188 KB Output isn't correct
11 Incorrect 0 ms 1188 KB Output isn't correct
12 Incorrect 0 ms 1188 KB Output isn't correct
13 Incorrect 0 ms 1188 KB Output isn't correct
14 Incorrect 0 ms 1188 KB Output isn't correct
15 Incorrect 0 ms 1188 KB Output isn't correct
16 Incorrect 4 ms 1188 KB Output isn't correct
17 Correct 0 ms 1188 KB Output is correct
18 Incorrect 0 ms 1188 KB Output isn't correct
19 Incorrect 0 ms 1188 KB Output isn't correct
20 Incorrect 4 ms 1188 KB Output isn't correct