답안 #165054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165054 2019-11-24T20:34:18 Z aZvezda 생물 실험 (IZhO13_expgorl) C++14
0 / 100
158 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;

ld sX, sY;
ld gX, gY;
ld dX, dY;
int k;
string s;

pair<ld, ld> eval(int q) {
    ld mn = 2 * mod, mx = -1;
    ld cX = gX + dX * (q - 1) - sX, cY = gY + dY * (q - 1) - sY;
    for(auto it : s) {
        ld curr = sqrt(cX * cX + cY * cY);
        mn = min(mn, curr);
        mx = max(mx, curr);
        if(it == 'L') {
            cX ++;
        } else if(it == 'R') {
            cX --;
        } else if(it == 'F') {
            cY ++;
        } else if(it == 'B') {
            cY --;
        }
    }
    return {mn, mx};
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> k >> s;
    s.push_back('I');
    cin >> sX >> sY;
    cin >> gX >> gY;
    for(auto it : s) {
        if(it == 'L') {
            dX ++;
        } else if(it == 'R') {
            dX --;
        } else if(it == 'F') {
            dY ++;
        } else if(it == 'B') {
            dY --;
        }
    }
    ld mn = 2 * mod, mx = -1;
    for(int i = 1; i <= k; i ++) {
        auto curr = eval(i);
        mn = min(mn, curr.first);
        mx = max(mn, curr.second);
    }
    cout << fixed << setprecision(12);
    cout << mn << " " << mx << endl;
    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 158 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -