# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
634967 | pragmatist | 생물 실험 (IZhO13_expgorl) | C++17 | 1 ms | 320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define ld long double
#define nl "\n"
using namespace std;
using pii = pair<int, int>;
const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
const int MOD = (int)1e9 + 7;
const int M = (int)5e4 + 7;
int k, Lx, Ly, Gx, Gy;
string a;
ll dist(int x1, int y1, int x2, int y2) {
return 1ll * (x1 - x2) * (x1 - x2) + 1ll * (y1 - y2) * (y1 - y2);
}
void solve() {
cin >> k >> a >> Lx >> Ly >> Gx >> Gy;
ll mn = INF, mx = -INF;
mn = min(mn, dist(Gx, Gy, Lx, Ly));
mx = max(mx, dist(Gx, Gy, Lx, Ly));
int dx = 0, dy = 0, curx = 0, cury = 0;
for(auto x : a) {
if(x == 'L') dx++;
if(x == 'R') dx--;
if(x == 'F') dy++;
if(x == 'B') dy--;
}
for(auto x : a) {
if(x == 'L') curx++;
if(x == 'R') curx--;
if(x == 'F') cury++;
if(x == 'B') cury--;
int l = 0, r = k - 1;
while(r - l >= 3) {
int m1 = l + (r - l) / 3;
int m2 = r - (r - l) / 3;
if(dist(Gx + curx + m1 * dx, Gy + cury + m1 * dy, Lx, Ly) < dist(Gx + curx + m2 * dx, Gy + cury + m2 * dy, Lx, Ly)) {
l = m1;
} else
r = m2;
}
for(int res = l; res <= r; ++res) {
int X = Gx + curx + res * dx, Y = Gy + cury + res * dy;
mn = min(mn, dist(X, Y, Lx, Ly));
mx = max(mx, dist(X, Y, Lx, Ly));
}
}
cout << fixed << setprecision(9) << sqrt(mn) << ' ' << sqrt(mx) << nl;
}
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test = 1;
//cin >> test;
while(test--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |