#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(p.x*p.x + 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;
if (dist(x + delta*M1, laser) < dist(x + delta*M2, laser))
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;
}
Compilation message
expgorl.cpp: In function 'int main()':
expgorl.cpp:73:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); i++)
~~^~~~~~~~~~
expgorl.cpp:81:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); i++)
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |