답안 #8197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
8197 2014-09-06T14:37:49 Z gs14004 생물 실험 (IZhO13_expgorl) C++
15 / 100
0 ms 1268 KB
#include <cstdio>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long lint;
typedef pair<lint,lint> pi;

int k;
char s[10005];
pi afterCycle, a[10005], laser, ainta, mp[150];
lint minv, maxv;

lint dist(pi x, pi y){
    return (y.second - x.second)*(y.second - x.second) + (y.first - x.first)*(y.first - x.first);
}
pi mv(pi x, int time){return pi(x.first + afterCycle.first * time, x.second + afterCycle.second * time);}
lint f(pi x, int t){return dist(laser,mv(x,t));}

void input(){
    scanf("%d %s",&k,s);
    scanf("%lld %lld %lld %lld",&laser.first,&laser.second,&ainta.first,&ainta.second);
    mp['I'] = pi(0ll,0ll);
    mp['L'] = pi(-1ll,0ll);
    mp['R'] = pi(1ll,0ll);
    mp['B'] = pi(0ll,-1ll);
    mp['F'] = pi(0ll,1ll);
}

int main(){
    input();
    minv = maxv = dist(laser,ainta);
    pi x = ainta;
    for (int i=0; s[i]; i++) {
        x.first += mp[s[i]].first;
        x.second += mp[s[i]].second;
        a[i] = x;
    }
    afterCycle = pi(x.first - ainta.first,x.second - ainta.second);
    for (int i=0; s[i]; i++) {
        int s = 0, e = k-1;
        while (e - s < 2){
            int m = (s+e)/2;
            if(f(a[i],m) < f(a[i],m+1)) e = m+1;
            else s = m;
        }
        minv = min(minv,f(a[i],s));
        minv = min(minv,f(a[i],e));
        maxv = max(maxv,f(a[i],0));
        maxv = max(maxv,f(a[i],k-1));
    }
    printf("%lf\n%lf",sqrt(minv),sqrt(maxv));
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1268 KB Output isn't correct
2 Incorrect 0 ms 1268 KB Output isn't correct
3 Correct 0 ms 1268 KB Output is correct
4 Incorrect 0 ms 1268 KB Output isn't correct
5 Incorrect 0 ms 1268 KB Output isn't correct
6 Incorrect 0 ms 1268 KB Output isn't correct
7 Incorrect 0 ms 1268 KB Output isn't correct
8 Incorrect 0 ms 1268 KB Output isn't correct
9 Incorrect 0 ms 1268 KB Output isn't correct
10 Incorrect 0 ms 1268 KB Output isn't correct
11 Correct 0 ms 1268 KB Output is correct
12 Incorrect 0 ms 1268 KB Output isn't correct
13 Incorrect 0 ms 1268 KB Output isn't correct
14 Incorrect 0 ms 1268 KB Output isn't correct
15 Incorrect 0 ms 1268 KB Output isn't correct
16 Incorrect 0 ms 1268 KB Output isn't correct
17 Correct 0 ms 1268 KB Output is correct
18 Incorrect 0 ms 1268 KB Output isn't correct
19 Incorrect 0 ms 1268 KB Output isn't correct
20 Incorrect 0 ms 1268 KB Output isn't correct