답안 #90555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90555 2018-12-22T11:45:54 Z popovicirobert 생물 실험 (IZhO13_expgorl) C++14
0 / 100
2 ms 380 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 ll dist(ll x, ll y) {
    return 1LL * x * x + 1LL * y * y;
}

string str;
int lx, ly, gx, gy;
double mn = 1e18, mx = 0;

inline void upd(ll cur) {
    mn = min(mn, 1.0 * cur);
    mx = max(mx, 1.0 * cur);
}

inline void solve(vector < pair <int, int> > pts, int k, int x, int y) {
    for(auto it : pts) {
        upd(dist(it.first, it.second));
        upd(dist(it.first + 1LL * k * x, it.second + 1LL * k * y));
        int res = -1;
        for(int step = 1 << 16; step; step >>= 1) {
            if(res + step < k && dist(it.first + 1LL * (res + step) * x, it.second + 1LL * (res + step) * y) >= dist(it.first + 1LL * (res + step + 1) * x, it.second + 1LL * (res + step + 1) * y)) {
                res += step;
            }
        }
        res++;
        upd(dist(it.first + 1LL * res * x, it.second + 1LL * res * y));
    }
}

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;
    int lx, ly, gx, gy;
    cin >> lx >> ly >> gx >> gy;
    gx -= lx, gy -= ly;
    dx['L'] = -1, dx['R'] = 1;
    dy['F'] = 1, dy['B'] = -1;
    vector < pair <int, int> > pts;
    int x = gx, y = gy;
    pts.push_back({x, y});
    for(auto it : str) {
        x += dx[it], y += dy[it];
        pts.push_back({x, y});
    }
    solve(pts, k, x - gx, y - gy);
    mn = sqrt(mn), mx = sqrt(mx);
    cout << fixed << setprecision(20) << mn << " " << mx;
    //cin.close();
    //cout.close();
    return 0;
}

Compilation message

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