답안 #90548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90548 2018-12-22T11:12:32 Z popovicirobert 생물 실험 (IZhO13_expgorl) C++14
0 / 100
69 ms 376 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MAXK = (int) 1e5;

char dx[256], dy[256];

inline double dist(double x1, double y1, double x2, double y2) {
    return 1.0 * (x1 - x2) * (x1 - x2) + 1.0 * (y1 - y2) * (y1 - y2);
}

inline void upd(double &mn, double &mx, double cur) {
    mn = min(mn, cur);
    mx = max(mx, cur);
}

string str;
double dst[MAXK + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> k >> str;
    double lx, ly, gx, gy;
    cin >> lx >> ly >> gx >> gy;
    dx['L'] = -1, dx['R'] = 1;
    dy['F'] = 1, dy['B'] = -1;
    int x = 0, y = 0;
    for(auto it : str) {
        x += dx[it], y += dy[it];
    }
    double mn = 1e18, mx = 0;
    if(x == 0 && y == 0) {
        upd(mn, mx, dist(lx, ly, gx, gy));
        for(auto it : str) {
            x += dx[it], y += dy[it];
            upd(mn, mx, dist(lx, ly, x + gx, y + gy));
        }
        cout << fixed << setprecision(20) << mn << " " << mx;
        return 0;
    }
    upd(mn, mx, dist(lx, ly, gx, gy));
    while(k > 0) {
        k--;
        for(auto it : str) {
            gx += dx[it], gy += dy[it];
            upd(mn, mx, dist(lx, ly, gx, gy));
        }
    }
    cout << fixed << setprecision(20) << mn << " " << mx;
    //cin.close();
    //cout.close();
    return 0;
}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:40:19: warning: array subscript has type 'char' [-Wchar-subscripts]
         x += dx[it], y += dy[it];
                   ^
expgorl.cpp:40:32: warning: array subscript has type 'char' [-Wchar-subscripts]
         x += dx[it], y += dy[it];
                                ^
expgorl.cpp:46:23: warning: array subscript has type 'char' [-Wchar-subscripts]
             x += dx[it], y += dy[it];
                       ^
expgorl.cpp:46:36: warning: array subscript has type 'char' [-Wchar-subscripts]
             x += dx[it], y += dy[it];
                                    ^
expgorl.cpp:56:24: warning: array subscript has type 'char' [-Wchar-subscripts]
             gx += dx[it], gy += dy[it];
                        ^
expgorl.cpp:56:38: warning: array subscript has type 'char' [-Wchar-subscripts]
             gx += dx[it], gy += dy[it];
                                      ^
expgorl.cpp:30:9: warning: unused variable 'i' [-Wunused-variable]
     int i, k;
         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -