# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
343202 | apostoldaniel854 | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 1 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
using ll = long long;
int k;
ll ans_max, ans_min;
void upd (ll val) {
if (ans_max < val)
ans_max = val;
if (ans_min > val)
ans_min = val;
}
ll dist (int x, int y) {
return 1ll * x * x + 1ll * y * y;
}
int main () {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
cin >> k;
string moves;
cin >> moves;
int laser_x, laser_y, gorlum_x, gorlum_y;
cin >> laser_x >> laser_y;
cin >> gorlum_x >> gorlum_y;
gorlum_x -= laser_x;
gorlum_y -= laser_y;
vector <pair <int, int>> points;
int x = 0, y = 0;
points.pb ({gorlum_x, gorlum_y});
for (char ch : moves) {
if (ch == 'L')
x--;
if (ch == 'R')
x++;
if (ch == 'F')
y++;
if (ch == 'B')
y--;
points.pb ({x + gorlum_x, y + gorlum_y});
}
ans_max = ans_min = dist (gorlum_x, gorlum_y);
for (pair <int, int> p : points) {
upd (dist (p.first, p.second));
upd (dist (p.first + (k - 1) * x, p.second + (k - 1) * y));
int lb = 0, rb = k - 1, best = 0;
while (lb < rb) {
int mid = (lb + rb) / 2;
int px = p.first + mid * x;
int py = p.second + mid * y;
if (dist (px, py) >= dist (px + x, py + y)) {
lb = mid + 1;
best = mid;
}
else {
rb = mid;
}
}
upd (dist (p.first + best * x, p.second + best * y));
}
cout << fixed << setprecision (9) << sqrt (ans_min) << " " << sqrt (ans_max) << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |