# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47537 | tieunhi | Experiments with Gorlum (IZhO13_expgorl) | C++14 | 9 ms | 1088 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second
#define PB push_back
#define N 100005
#define maxc 1000000007
using namespace std;
using db = long double;
struct Point
{
int x, y;
Point operator + (Point p) const {
return {x + p.x, y + p.y};
}
Point operator - (Point p) const {
return {x - p.x, y - p.y};
}
Point operator * (int k) const {
return {x*k, y*k};
}
}laser, gorlum, delta, f[5];
int K;
vector<Point> all;
string s;
string SS = "LRFBI";
db dist(Point p, Point q)
{
p = p - q;
return sqrt(1ll*p.x*p.x + 1ll*p.y*p.y);
}
void setup()
{
f[0] = {-1, 0};
f[1] = {1, 0};
f[2] = {0, 1};
f[3] = {0, -1};
f[4] = {0, 0};
cin >> K >> s;
cin >> laser.x >> laser.y;
cin >> gorlum.x >> gorlum.y;
}
void solve(Point x, db &vMin, db &vMax)
{
int L = 0, R = K-1;
while (R - L > 2)
{
int M1 = L + (R - L)/3;
int M2 = R - (R - L)/3;
db xx = dist(x + delta*M1, laser);
db yy = dist(x + delta*M2, laser);
if (xx < yy)
R = M2;
else L = M1;
}
for (int i = L; i <= R; i++)
vMin = min(vMin, dist(x + delta*i, laser));
vMax = max(vMax, dist(x, laser));
vMax = max(vMax, dist(x + delta*(K-1), laser));
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("INP.TXT", "r", stdin);
setup();
Point cur = gorlum;
for (int i = 0; i < s.size(); i++)
{
all.PB(cur);
int typeId = SS.find(s[i]);
cur = cur + f[typeId];
}
delta = cur - gorlum;
db resMax = 0, resMin = 1e15;
for (int i = 0; i < s.size(); i++)
solve(all[i], resMin, resMax);
cout<<fixed<<setprecision(9)<<resMin<<" ";
cout<<fixed<<setprecision(9)<<resMax;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |