cosenza987

fak

Oct 30th, 2025
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.38 KB | None | 0 0
  1. //Слава Україні, Героям слава
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define st first
  8. #define nd second
  9. #define pb push_back
  10. #define cl(x,v) memset((x), (v), sizeof(x))
  11. #define db(x) cerr << #x << " == " << x << endl
  12. #define dbs(x) cerr << x << endl
  13. #define _ << ", " <<
  14.  
  15. typedef long long ll;
  16. typedef long double ld;
  17. typedef pair<int, int> pii;
  18. typedef pair<int, pii> piii;
  19. typedef pair<ll, ll> pll;
  20. typedef pair<ll, pll> plll;
  21. typedef vector<int> vi;
  22. typedef vector <vi> vii;
  23.  
  24. const ld EPS = 1e-7, PI = acos(-1.);
  25. const ll LINF = 0x3f3f3f3f3f3f3f3f;
  26. const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
  27. const int N = 1e5 + 5;
  28.  
  29. //for big coordinates change to long long
  30. typedef long double type;
  31.  
  32. /* The functions above are for:
  33.     ge => greater or equal
  34.     le => lesser or equal
  35.     eq => equal
  36.     sign => sign of a number (+ or -)
  37. */
  38. bool ge(type x, type y) { return x > y - EPS; }
  39. bool le(type x, type y) { return x - EPS < y; }
  40. bool eq(type x, type y) { return ge(x, y) and le(x, y); }
  41. int sign(type x) { return ge(x, 0) - le(x, 0); }
  42.  
  43. struct point {
  44.     type x, y;
  45.  
  46.     point() : x(0), y(0) {}
  47.     point(type _x, type _y) : x(_x), y(_y) {}
  48.  
  49.     point operator -() { return point(-x, -y); }
  50.     point operator +(point p) { return point(x + p.x, y + p.y); }
  51.     point operator -(point p) { return point(x - p.x, y - p.y); }
  52.  
  53.     point operator *(type k) { return point(x * k, y * k); }
  54.     point operator /(type k) { return point(x / k, y / k); }
  55.  
  56.     //inner product
  57.     type operator *(point p) { return x * p.x + y * p.y; }
  58.     //cross product
  59.     type operator %(point p) { return x * p.y - y * p.x; }
  60.  
  61.     bool operator ==(const point& p) const { return x == p.x and y == p.y; }
  62.     bool operator !=(const point& p) const { return x != p.x or y != p.y; }
  63.     bool operator <(const point& p) const { return (x < p.x) or (x == p.x and y < p.y); }
  64.  
  65.     // 0 => same direction
  66.     // 1 => other is on the left
  67.     //-1 => other is on the right
  68.     int dir(point origin, point other) {
  69.         type d = (*this - origin) % (other - origin);
  70.         return ge(d, 0) - le(d, 0);
  71.     }
  72.  
  73.     bool on_seg(point p, point q) {
  74.         if (this->dir(p, q)) return 0;
  75.         return ge(x, min(p.x, q.x)) and le(x, max(p.x, q.x)) and ge(y, min(p.y, q.y)) and le(y, max(p.y, q.y));
  76.     }
  77.  
  78.     ld abs() { return sqrt(x * x + y * y); }
  79.     type abs2() { return x * x + y * y; }
  80.     ld dist(point q) { return (*this - q).abs(); }
  81.     type dist2(point q) { return (*this - q).abs2(); }
  82.  
  83.     ld arg() { return atan2l(y, x); }
  84.  
  85.     // Project point on vector y
  86.     point project(point y) { return y * ((*this * y) / (y * y)); }
  87.  
  88.     // Project point on line generated by points x and y
  89.     point project(point x, point y) { return x + (*this - x).project(y - x); }
  90.  
  91.     ld dist_line(point x, point y) { return dist(project(x, y)); }
  92.  
  93.     ld dist_seg(point x, point y) {
  94.         return project(x, y).on_seg(x, y) ? dist_line(x, y) : min(dist(x), dist(y));
  95.     }
  96.  
  97.     point rotate(ld sin, ld cos) { return point(cos * x - sin * y, sin * x + cos * y); }
  98.     point rotate(ld a) { return rotate(sin(a), cos(a)); }
  99.  
  100.     // rotate around the argument of vector p
  101.     point rotate(point p) { return rotate(p.y / p.abs(), p.x / p.abs()); }
  102.  
  103. };
  104.  
  105. int direction(point origin, point p, point other) { return p.dir(origin, other); }
  106.  
  107. //rotates 90 degrees counter clockwise
  108. point rotate_ccw90(point p) { return point(-p.y, p.x); }
  109. //rotates 90 degrees clockwise
  110. point rotate_cw90(point p) { return point(p.y, -p.x); }
  111.  
  112. //for reading purposes avoid using * and % operators, use the functions below:
  113. type dot(point p, point q) { return p.x * q.x + p.y * q.y; }
  114. type cross(point p, point q) { return p.x * q.y - p.y * q.x; }
  115.  
  116. //twice the area of a triangle
  117. type area_2(point a, point b, point c) { return cross(a, b) + cross(b, c) + cross(c, a); }
  118.  
  119. /*Compares the absolute angle defined by (a1 and b1) vs angle defined by (a2 and b2)
  120.     1  : bigger
  121.     -1 : smaller
  122.     0  : equal
  123. Example:
  124.     angle_less(point(1, 0) , point(0, 1), point(-1, 0), point(-1, -1)) == 1
  125.  
  126.     the angle formed by the two first vectors is 90 degrees
  127.     the angle formed by the two last vectors is 45 degrees
  128. */
  129. int angle_less(const point& a1, const point& b1, const point& a2, const point& b2) {
  130.     point p1(dot(a1, b1), abs(cross(a1, b1)));
  131.     point p2(dot(a2, b2), abs(cross(a2, b2)));
  132.     if (cross(p1, p2) < 0) return 1;
  133.     if (cross(p1, p2) > 0) return -1;
  134.     return 0;
  135. }
  136.  
  137. ostream& operator<<(ostream& os, const point& p) {
  138.     os << "(" << p.x << "," << p.y << ")";
  139.     return os;
  140. }
  141.  
  142. point project_point_line(point c, point a, point b) {
  143.     ld r = dot(b - a, b - a);
  144.     if (fabs(r) < EPS) return a;
  145.     return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a);
  146. }
  147.  
  148. point project_point_ray(point c, point a, point b) {
  149.     ld r = dot(b - a, b - a);
  150.     if (fabs(r) < EPS) return a;
  151.     r = dot(c - a, b - a) / r;
  152.     if (le(r, 0)) return a;
  153.     return a + (b - a) * r;
  154. }
  155.  
  156. point project_point_segment(point c, point a, point b) {
  157.     ld r = dot(b - a, b - a);
  158.     if (fabs(r) < EPS) return a;
  159.     r = dot(c - a, b - a) / r;
  160.     if (le(r, 0)) return a;
  161.     if (ge(r, 1)) return b;
  162.     return a + (b - a) * r;
  163. }
  164.  
  165. ld distance_point_line(point c, point a, point b) {
  166.     return c.dist2(project_point_line(c, a, b));
  167. }
  168.  
  169. ld distance_point_ray(point c, point a, point b) {
  170.     return c.dist2(project_point_ray(c, a, b));
  171. }
  172.  
  173. ld distance_point_segment(point c, point a, point b) {
  174.     return c.dist2(project_point_segment(c, a, b));
  175. }
  176.  
  177. //not tested
  178. ld distance_point_plane(ld x, ld y, ld z,
  179.     ld a, ld b, ld c, ld d)
  180. {
  181.     return fabs(a * x + b * y + c * z - d) / sqrt(a * a + b * b + c * c);
  182. }
  183.  
  184. bool lines_parallel(point a, point b, point c, point d) {
  185.     return fabs(cross(b - a, d - c)) < EPS;
  186. }
  187.  
  188. bool lines_collinear(point a, point b, point c, point d) {
  189.     return lines_parallel(a, b, c, d)
  190.         && fabs(cross(a - b, a - c)) < EPS
  191.         && fabs(cross(c - d, c - a)) < EPS;
  192. }
  193.  
  194. point lines_intersect(point p, point q, point a, point b) {
  195.     point r = q - p, s = b - a, c(p % q, a % b);
  196.     if (eq(r % s, 0)) return point(LINF, LINF);
  197.     return point(point(r.x, s.x) % c, point(r.y, s.y) % c) / (r % s);
  198. }
  199.  
  200. //be careful: test line_line_intersection before using this function
  201. point compute_line_intersection(point a, point b, point c, point d) {
  202.     b = b - a; d = c - d; c = c - a;
  203.     assert(dot(b, b) > EPS && dot(d, d) > EPS);
  204.     return a + b * cross(c, d) / cross(b, d);
  205. }
  206.  
  207. bool line_line_intersect(point a, point b, point c, point d) {
  208.     if (!lines_parallel(a, b, c, d)) return true;
  209.     if (lines_collinear(a, b, c, d)) return true;
  210.     return false;
  211. }
  212.  
  213. //rays in direction a -> b, c -> d
  214. bool ray_ray_intersect(point a, point b, point c, point d) {
  215.     if (a.dist2(c) < EPS || a.dist2(d) < EPS ||
  216.         b.dist2(c) < EPS || b.dist2(d) < EPS) return true;
  217.     if (lines_collinear(a, b, c, d)) {
  218.         if (ge(dot(b - a, d - c), 0)) return true;
  219.         if (ge(dot(a - c, d - c), 0)) return true;
  220.         return false;
  221.     }
  222.     if (!line_line_intersect(a, b, c, d)) return false;
  223.     point inters = lines_intersect(a, b, c, d);
  224.     if (ge(dot(inters - c, d - c), 0) && ge(dot(inters - a, b - a), 0)) return true;
  225.     return false;
  226. }
  227.  
  228. bool segment_segment_intersect(point a, point b, point c, point d) {
  229.     if (a.dist2(c) < EPS || a.dist2(d) < EPS ||
  230.         b.dist2(c) < EPS || b.dist2(d) < EPS) return true;
  231.     int d1, d2, d3, d4;
  232.     d1 = direction(a, b, c);
  233.     d2 = direction(a, b, d);
  234.     d3 = direction(c, d, a);
  235.     d4 = direction(c, d, b);
  236.     if (d1 * d2 < 0 and d3 * d4 < 0) return 1;
  237.     return a.on_seg(c, d) or b.on_seg(c, d) or
  238.         c.on_seg(a, b) or d.on_seg(a, b);
  239. }
  240.  
  241. bool segment_line_intersect(point a, point b, point c, point d) {
  242.     if (!line_line_intersect(a, b, c, d)) return false;
  243.     point inters = lines_intersect(a, b, c, d);
  244.     if (inters.on_seg(a, b)) return true;
  245.     return false;
  246. }
  247.  
  248. //ray in direction c -> d
  249. bool segment_ray_intersect(point a, point b, point c, point d) {
  250.     if (a.dist2(c) < EPS || a.dist2(d) < EPS ||
  251.         b.dist2(c) < EPS || b.dist2(d) < EPS) return true;
  252.     if (lines_collinear(a, b, c, d)) {
  253.         if (c.on_seg(a, b)) return true;
  254.         if (ge(dot(d - c, a - c), 0)) return true;
  255.         return false;
  256.     }
  257.     if (!line_line_intersect(a, b, c, d)) return false;
  258.     point inters = lines_intersect(a, b, c, d);
  259.     if (!inters.on_seg(a, b)) return false;
  260.     if (ge(dot(inters - c, d - c), 0)) return true;
  261.     return false;
  262. }
  263.  
  264. //ray in direction a -> b
  265. bool ray_line_intersect(point a, point b, point c, point d) {
  266.     if (a.dist2(c) < EPS || a.dist2(d) < EPS ||
  267.         b.dist2(c) < EPS || b.dist2(d) < EPS) return true;
  268.     if (!line_line_intersect(a, b, c, d)) return false;
  269.     point inters = lines_intersect(a, b, c, d);
  270.     if (!line_line_intersect(a, b, c, d)) return false;
  271.     if (ge(dot(inters - a, b - a), 0)) return true;
  272.     return false;
  273. }
  274.  
  275. ld distance_segment_line(point a, point b, point c, point d) {
  276.     if (segment_line_intersect(a, b, c, d)) return 0;
  277.     return min(distance_point_line(a, c, d), distance_point_line(b, c, d));
  278. }
  279.  
  280. ld distance_segment_ray(point a, point b, point c, point d) {
  281.     if (segment_ray_intersect(a, b, c, d)) return 0;
  282.     ld min1 = distance_point_segment(c, a, b);
  283.     ld min2 = min(distance_point_ray(a, c, d), distance_point_ray(b, c, d));
  284.     return min(min1, min2);
  285. }
  286.  
  287. ld distance_segment_segment(point a, point b, point c, point d) {
  288.     if (segment_segment_intersect(a, b, c, d)) return 0;
  289.     ld min1 = min(distance_point_segment(c, a, b), distance_point_segment(d, a, b));
  290.     ld min2 = min(distance_point_segment(a, c, d), distance_point_segment(b, c, d));
  291.     return min(min1, min2);
  292. }
  293.  
  294. ld distance_ray_line(point a, point b, point c, point d) {
  295.     if (ray_line_intersect(a, b, c, d)) return 0;
  296.     ld min1 = distance_point_line(a, c, d);
  297.     return min1;
  298. }
  299.  
  300. ld distance_ray_ray(point a, point b, point c, point d) {
  301.     if (ray_ray_intersect(a, b, c, d)) return 0;
  302.     ld min1 = min(distance_point_ray(c, a, b), distance_point_ray(a, c, d));
  303.     return min1;
  304. }
  305.  
  306. ld distance_line_line(point a, point b, point c, point d) {
  307.     if (line_line_intersect(a, b, c, d)) return 0;
  308.     return distance_point_line(a, c, d);
  309. }
  310.  
  311. struct circle {
  312.     point c;
  313.     ld r;
  314.     circle() { c = point(); r = 0; }
  315.     circle(point _c, ld _r) : c(_c), r(_r) {}
  316.     ld area() { return acos(-1.0) * r * r; }
  317.     ld chord(ld rad) { return  2 * r * sin(rad / 2.0); }
  318.     ld sector(ld rad) { return 0.5 * rad * area() / acos(-1.0); }
  319.     bool intersects(circle other) {
  320.         return le(c.dist(other.c), r + other.r);
  321.     }
  322.     bool contains(point p) { return le(c.dist(p), r); }
  323.     pair<point, point> getTangentPoint(point p) {
  324.         ld d1 = c.dist(p), theta = asin(r / d1);
  325.         point p1 = (c - p).rotate(-theta);
  326.         point p2 = (c - p).rotate(theta);
  327.         p1 = p1 * (sqrt(d1 * d1 - r * r) / d1) + p;
  328.         p2 = p2 * (sqrt(d1 * d1 - r * r) / d1) + p;
  329.         return make_pair(p1, p2);
  330.     }
  331. };
  332.  
  333. circle circumcircle(point a, point b, point c) {
  334.     circle ans;
  335.     point u = point((b - a).y, -(b - a).x);
  336.     point v = point((c - a).y, -(c - a).x);
  337.     point n = (c - b) * 0.5;
  338.     ld t = cross(u, n) / cross(v, u);
  339.     ans.c = ((a + c) * 0.5) + (v * t);
  340.     ans.r = ans.c.dist(a);
  341.     return ans;
  342. }
  343.  
  344. point compute_circle_center(point a, point b, point c) {
  345.     //circumcenter
  346.     b = (a + b) / 2;
  347.     c = (a + c) / 2;
  348.     return compute_line_intersection(b, b + rotate_cw90(a - b), c, c + rotate_cw90(a - c));
  349. }
  350.  
  351. int inside_circle(point p, circle c) {
  352.     if (fabs(p.dist(c.c) - c.r) < EPS) return 1;
  353.     else if (p.dist(c.c) < c.r) return 0;
  354.     else return 2;
  355. } //0 = inside/1 = border/2 = outside
  356.  
  357. circle incircle(point p1, point p2, point p3) {
  358.     ld m1 = p2.dist(p3);
  359.     ld m2 = p1.dist(p3);
  360.     ld m3 = p1.dist(p2);
  361.     point c = (p1 * m1 + p2 * m2 + p3 * m3) * (1 / (m1 + m2 + m3));
  362.     ld s = 0.5 * (m1 + m2 + m3);
  363.     ld r = sqrt(s * (s - m1) * (s - m2) * (s - m3)) / s;
  364.     return circle(c, r);
  365. }
  366.  
  367. circle minimum_circle(vector<point> p) {
  368.     random_shuffle(p.begin(), p.end());
  369.     circle C = circle(p[0], 0.0);
  370.     for (int i = 0; i < (int)p.size(); i++) {
  371.         if (C.contains(p[i])) continue;
  372.         C = circle(p[i], 0.0);
  373.         for (int j = 0; j < i; j++) {
  374.             if (C.contains(p[j])) continue;
  375.             C = circle((p[j] + p[i]) * 0.5, 0.5 * p[j].dist(p[i]));
  376.             for (int k = 0; k < j; k++) {
  377.                 if (C.contains(p[k])) continue;
  378.                 C = circumcircle(p[j], p[i], p[k]);
  379.             }
  380.         }
  381.     }
  382.     return C;
  383. }
  384.  
  385. // compute intersection of line through points a and b with
  386. // circle centered at c with radius r > 0
  387. vector<point> circle_line_intersection(point a, point b, point c, ld r) {
  388.     vector<point> ret;
  389.     b = b - a;
  390.     a = a - c;
  391.     ld A = dot(b, b);
  392.     ld B = dot(a, b);
  393.     ld C = dot(a, a) - r * r;
  394.     ld D = B * B - A * C;
  395.     if (D < -EPS) return ret;
  396.     ret.push_back(c + a + b * (sqrt(D + EPS) - B) / A);
  397.     if (D > EPS)
  398.         ret.push_back(c + a + b * (-B - sqrt(D)) / A);
  399.     return ret;
  400. }
  401.  
  402. vector<point> circle_circle_intersection(point a, point b, ld r, ld R) {
  403.     vector<point> ret;
  404.     ld d = sqrt(a.dist2(b));
  405.     if (d > r + R || d + min(r, R) < max(r, R)) return ret;
  406.     ld x = (d * d - R * R + r * r) / (2 * d);
  407.     ld y = sqrt(r * r - x * x);
  408.     point v = (b - a) / d;
  409.     ret.push_back(a + v * x + rotate_ccw90(v) * y);
  410.     if (y > 0)
  411.         ret.push_back(a + v * x - rotate_ccw90(v) * y);
  412.     return ret;
  413. }
  414.  
  415. //GREAT CIRCLE
  416.  
  417. double gcTheta(double pLat, double pLong, double qLat, double qLong) {
  418.     pLat *= acos(-1.0) / 180.0; pLong *= acos(-1.0) / 180.0; // convert degree to radian
  419.     qLat *= acos(-1.0) / 180.0; qLong *= acos(-1.0) / 180.0;
  420.     return acos(cos(pLat) * cos(pLong) * cos(qLat) * cos(qLong) +
  421.         cos(pLat) * sin(pLong) * cos(qLat) * sin(qLong) +
  422.         sin(pLat) * sin(qLat));
  423. }
  424.  
  425. double gcDistance(double pLat, double pLong, double qLat, double qLong, double radius) {
  426.     return radius * gcTheta(pLat, pLong, qLat, qLong);
  427. }
  428.  
  429. // getting the angle at point b
  430. long double angle(point a, point b, point c) {
  431.     long double ab = a.dist(b), ac = a.dist(c), bc = b.dist(c);
  432.     long double tmp = ab * ab + bc * bc - ac * ac;
  433.     tmp /= 2 * ab * bc;
  434.     return fabs(acosl(tmp));
  435. }
  436.  
  437. int main() {
  438.     ios_base::sync_with_stdio(false);
  439.     cin.tie(nullptr);
  440.     cout << setprecision(15) << fixed;
  441.     int n;
  442.     cin >> n;
  443.     vector<point> v(n);
  444.     for(int i = 0; i < n; i++) {
  445.         cin >> v[i].x >> v[i].y;
  446.     }
  447.     long double ans = 0;
  448.     for(int i = 0; i < n; i++) {
  449.         // cout << i << "\n";
  450.         point pr = v[(i - 1 + n) % n], prr = v[(i - 2 + n) % n], pl = v[(i + 1) % n], pll = v[(i + 2) % n];
  451.         point mid = (pl + pr) / 2;
  452.         long double base = pl.dist(v[i]) + pr.dist(v[i]);
  453.         long double rad = pl.dist(pr) / 2;
  454.         point p = mid + rotate_ccw90((pr - pl) / 2);
  455.         if(direction(pll, pl, p) == -1 and direction(prr, pr, p) == 1 and ge(angle(pll, pl, p), PI / 2) and ge(angle(prr, pr, p), PI / 2)) {
  456.             // cout << "on circle\n";
  457.             // cout << rad * 2 * sqrtl(2) - base << "\n";
  458.             ans = max(ans, rad * 2 * sqrtl(2) - base);
  459.         }
  460.         if(line_line_intersect(pll, pl, prr, pr)) {
  461.             point inter = lines_intersect(pll, pl, prr, pr);
  462.             if(direction(pl, pr, inter) == 1 and ge(angle(pl, inter, pr), PI / 2)) {
  463.                 // cout << "line line intersect\n";
  464.                 // cout << pl.dist(inter) + pr.dist(inter) - base << "\n";
  465.                 // cout << inter << "\n";
  466.                 // cout << direction(pl, pr, inter) << "\n";
  467.                 ans = max(ans, pl.dist(inter) + pr.dist(inter) - base);
  468.             }
  469.         }
  470.         //maybe middle do not work so grab the arc
  471.         //each point will have a left boundary and right boundary which by default is arc(pl, pr), but maybe the possible arc is smaller than the whole arc
  472.         point pr_lb = pl, pr_rb = pr, pl_lb = pl, pl_rb = pr;
  473.         auto inter = circle_line_intersection(pl, pll, mid, rad);
  474.         for(auto a : inter) {
  475.             if(direction(prr, pr, a) == 1 and direction(pl, pr, a) != -1) {
  476.                 // cout << "circle line left\n";
  477.                 // cout << pl.dist(a) + pr.dist(a) - base << "\n";
  478.                 // cout << a << "\n";
  479.                 ans = max(ans, pl.dist(a) + pr.dist(a) - base);
  480.                 pl_lb = a;
  481.             }
  482.         }
  483.         inter = circle_line_intersection(pr, prr, mid, rad);
  484.         for(auto a : inter) {
  485.             if (direction(pll, pl, a) == -1 and direction(pl, pr, a) != -1) {
  486.                 // cout << "circle line right\n";
  487.                 // cout << pl.dist(a) + pr.dist(a) - base << "\n";
  488.                 // cout << a << "\n";
  489.                 ans = max(ans, pl.dist(a) + pr.dist(a) - base);
  490.                 pr_rb = a;
  491.             }
  492.         }
  493.         inter = circle_line_intersection(pr, pr + rotate_ccw90(pr - prr), mid, rad);
  494.         for(auto a : inter) {
  495.             if(eq(a.dist(pr), 0)) continue;
  496.             if(direction(pl, pr, a) != -1) pr_lb = a;
  497.         }
  498.         inter = circle_line_intersection(pl, pl + rotate_cw90(pl - pll), mid, rad);
  499.         for(auto a : inter) {
  500.             if(eq(a.dist(pl), 0)) continue;
  501.             if(direction(pl, pr, a) != -1) pl_rb = a;
  502.         }
  503.         //use boundaries to update answer, it will either improve or stay the same, e.g. boundary is pl or pr.
  504.         //for each boundary point it must be inside the boundary defined by the other point, e.g. pl_al must be inside the arc(pr_al, pr_ar).
  505.         //pr_lb
  506.         if (direction(mid, pl_lb, pr_lb) != 1 and direction(mid, pl_rb, pr_lb) != -1) ans = max(ans, pl.dist(pr_lb) + pr.dist(pr_lb) - base);
  507.         //pr_rb
  508.         if (direction(mid, pl_lb, pr_rb) != 1 and direction(mid, pl_rb, pr_rb) != -1) ans = max(ans, pl.dist(pr_rb) + pr.dist(pr_rb) - base);
  509.         //pl_lb
  510.         if (direction(mid, pr_lb, pl_lb) != 1 and direction(mid, pr_rb, pl_lb) != -1) ans = max(ans, pl.dist(pl_lb) + pr.dist(pl_lb) - base);
  511.         //pl_rb
  512.         if (direction(mid, pr_lb, pl_rb) != 1 and direction(mid, pr_rb, pl_rb) != -1) ans = max(ans, pl.dist(pl_rb) + pr.dist(pl_rb) - base);
  513.     }
  514.     cout << ans << "\n";
  515.     return 0;
  516. }
  517.  
Add Comment
Please, Sign In to add comment