QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796513#9808. Fragile Pinballucup-team296WA 41ms2384kbRust42.7kb2024-12-01 20:07:272024-12-01 20:07:28

Judging History

This is the latest submission verdict.

  • [2024-12-01 20:07:28]
  • Judged
  • Verdict: WA
  • Time: 41ms
  • Memory: 2384kb
  • [2024-12-01 20:07:27]
  • Submitted

answer

// https://contest.ucup.ac/contest/1865/problem/9808
pub mod solution {
//{"name":"K. Fragile Pinball","group":"Universal Cup - The 3rd Universal Cup. Stage 19: Shenyang","url":"https://contest.ucup.ac/contest/1865/problem/9808","interactive":false,"timeLimit":1000,"tests":[{"input":"3\n4 0\n0 3\n0 -1\n","output":"5.000000000000000000\n8.000000000000000000\n8.868185038797563409\n12.210024810881955830\n"},{"input":"3\n4 0\n0 3\n0 2\n","output":"5.000000000000000000\n5.366563145999495272\n6.111919138499425171\n6.782203304416628317\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"KFragilePinball"}}}

use crate::algo_lib::collections::permutation::Permutation;
#[allow(unused)]
use crate::dbg;
use crate::algo_lib::geometry::line::Line;
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::geometry::segment::SegmentT;
use crate::algo_lib::geometry::segment_intersection::inside_bounding_box;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::gen_vector::gen_vec;
use crate::algo_lib::misc::num_traits::HasConstants;
use crate::algo_lib::misc::ord_f64::OrdF64;

type Point = PointT<OrdF64>;
type Segment = SegmentT<OrdF64>;

fn mirror_polygon(polygon: Vec<Point>, line: Line) -> Vec<Point> {
    polygon.into_iter().map(|p| line.mirror(p)).collect()
}

const MX: OrdF64 = OrdF64(1e9);
const EPS: OrdF64 = OrdF64(1e-9);

fn intersect(polygon: &[Point], line: &Line) -> (OrdF64, OrdF64) {
    let mut res = vec![];
    for i in 0..polygon.len() {
        let p1 = polygon[i];
        let p2 = polygon[(i + 1) % polygon.len()];
        if let Some(p) = line.intersect(&Line::new(&p1, &p2)) {
            if inside_bounding_box(&Segment::new(p1, p2), &p) {
                res.push(line.project(p));
            }
        }
    }
    res.sort();
    if res.is_empty() {
        (MX, -MX)
    } else {
        (res[0], *res.last().unwrap())
    }
}

fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
    let n = input.usize();
    let a = gen_vec(n, |_| Point::new(input.f64(), input.f64()));
    let mut res = vec![OrdF64::ZERO; n + 1];
    let mut perm = Permutation::new(n);
    loop {
        let mut polygons = vec![a.clone()];
        for idx in 0..n {
            let edge_id = perm[idx];
            let prev_polygon = polygons[idx].clone();
            let line = Line::new(&prev_polygon[edge_id], &prev_polygon[(edge_id + 1) % n]);
            let new_polygon = mirror_polygon(prev_polygon, line);
            polygons.push(new_polygon);
        }
        for idx in (1..n).step_by(2) {
            polygons[idx].reverse();
        }
        let mut all_points = vec![];
        for polygon in polygons.iter() {
            all_points.extend(polygon.iter().cloned());
        }
        for &p1 in all_points.iter() {
            for &p2 in all_points.iter() {
                if p1.dist_manh(&p2) < EPS {
                    continue;
                }
                let line = Line::new(&p1, &p2);
                let intersections: Vec<_> = polygons
                    .iter()
                    .map(|polygon| intersect(polygon, &line))
                    .collect();
                if intersections[0].0 != MX {
                    let mut seg = intersections[0];
                    res[0] = res[0].max(seg.1 - seg.0);
                    for i in 1..intersections.len() {
                        if intersections[i].0 > seg.1 + EPS {
                            break;
                        }
                        seg.1 = seg.1.max(intersections[i].1);
                        res[i] = res[i].max(seg.1 - seg.0);
                    }
                }
            }
        }
        if !perm.next() {
            break;
        }
    }
    let mut pref_max = OrdF64::ZERO;
    for x in res.into_iter() {
        pref_max = pref_max.max(x);
        out.println(pref_max);
    }
}

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    solve(&mut input, &mut output, 1);
    output.flush();
    true
}

}
pub mod algo_lib {
#![feature(test)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]

pub mod collections {
pub mod permutation {
use std::ops::Index;
use std::ops::Range;

pub struct Permutation {
    ids: Vec<usize>,
    pos_of_element: Vec<usize>,
}

impl std::fmt::Debug for Permutation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_fmt(format_args!("{:?}", self.ids))
    }
}

impl Permutation {
    pub fn new(n: usize) -> Self {
        Self::from_vec((0..n).collect())
    }

    pub fn from_vec(ids: Vec<usize>) -> Self {
        let n = ids.len();
        let mut pos_of_element = vec![0; n];
        for (pos, &val) in ids.iter().enumerate() {
            pos_of_element[val] = pos;
        }
        Self {
            ids,
            pos_of_element,
        }
    }

    pub fn get_pos_of_element(&self, value: usize) -> usize {
        let res = self.pos_of_element[value];
        debug_assert_eq!(self.ids[res], value);
        res
    }

    pub fn swap(&mut self, p1: usize, p2: usize) {
        self.ids.swap(p1, p2);
        self.pos_of_element[self.ids[p1]] = p1;
        self.pos_of_element[self.ids[p2]] = p2;
    }

    fn reverse(&mut self, r: Range<usize>) {
        let mut start = r.start;
        let mut end = r.end;
        while start < end {
            end -= 1;
            self.swap(start, end);
            start += 1;
        }
    }

    #[allow(clippy::should_implement_trait)]
    pub fn next(&mut self) -> bool {
        for pos in (1..(self.ids.len())).rev() {
            if self.ids[pos - 1] < self.ids[pos] {
                for pos2 in (pos..self.ids.len()).rev() {
                    if self.ids[pos - 1] < self.ids[pos2] {
                        self.swap(pos - 1, pos2);
                        self.reverse(pos..self.ids.len());
                        return true;
                    }
                }
                unreachable!();
            }
        }
        false
    }

    #[allow(clippy::len_without_is_empty)]
    pub fn len(&self) -> usize {
        self.ids.len()
    }
}

impl Index<usize> for Permutation {
    type Output = usize;

    fn index(&self, index: usize) -> &Self::Output {
        &self.ids[index]
    }
}
}
}
pub mod geometry {
pub mod direction {
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::misc::num_traits::Number;
use std::cmp::Ordering;

///
/// Sorted counter-clock-wise
/// starting from (0;0) -> (inf; 0)
///
pub struct DirectionT<T>(PointT<T>)
where
    T: Number;

#[derive(Ord, PartialOrd, Eq, PartialEq)]
enum Side {
    PositiveY,
    NegativeY,
}

impl<T> DirectionT<T>
where
    T: Number,
{
    pub fn new(from: PointT<T>, to: PointT<T>) -> Self {
        Self(to - from)
    }

    pub fn inverse(&self) -> Self {
        Self(PointT::ZERO - self.0)
    }

    fn side(&self) -> Side {
        if self.0.y > T::ZERO || (self.0.y == T::ZERO && self.0.x >= T::ZERO) {
            Side::PositiveY
        } else {
            Side::NegativeY
        }
    }
}

impl<T> PartialEq<Self> for DirectionT<T>
where
    T: Number + Ord,
{
    fn eq(&self, other: &Self) -> bool {
        self.cmp(other) == Ordering::Equal
    }
}

impl<T> Eq for DirectionT<T> where T: Number + Ord {}

impl<T> PartialOrd<Self> for DirectionT<T>
where
    T: Number + Ord,
{
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(
            self.side().cmp(&other.side()).then(
                PointT::<T>::vect_mul2(&self.0, &other.0)
                    .cmp(&T::ZERO)
                    .reverse(),
            ),
        )
    }
}

impl<T> Ord for DirectionT<T>
where
    T: Number + Ord,
{
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}
}
pub mod line {
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::math::gcd::gcd;
use crate::algo_lib::misc::num_traits::HasConstants;
use crate::algo_lib::misc::ord_f64::OrdF64;
use std::fmt::Debug;

type Point = PointT<OrdF64>;

// a*x + b*y + c = 0
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Line {
    pub a: OrdF64,
    pub b: OrdF64,
    pub c: OrdF64,
}

impl Line {
    pub fn new(p1: &Point, p2: &Point) -> Self {
        let a = p2.y - p1.y;
        let b = p1.x - p2.x;
        let res = Self {
            a,
            b,
            c: -(p1.x * a + p1.y * b),
        };
        debug_assert!(res.on_line(p1));
        debug_assert!(res.on_line(p2));
        res
    }

    pub fn new_gcd(p1: (i64, i64), p2: (i64, i64)) -> Self {
        let mut a = p2.1 - p1.1;
        let mut b = p1.0 - p2.0;
        let mut c = -(p1.0 * a + p1.1 * b);
        let mut g = gcd(a, b);
        g = gcd(g, c);
        g = g.abs();
        a /= g;
        b /= g;
        c /= g;
        Self {
            a: a.into(),
            b: b.into(),
            c: c.into(),
        }
    }

    pub fn norm(&mut self) {
        if self.a > OrdF64::EPS {
        } else if self.a < -OrdF64::EPS {
            self.a = -self.a;
            self.b = -self.b;
            self.c = -self.c;
        } else if self.b > OrdF64::EPS {
            return;
        } else if self.b < -OrdF64::EPS {
            self.b = -self.b;
            self.c = -self.c;
        }
    }

    pub fn new3(mut a: i64, mut b: i64, mut c: i64) -> Self {
        let mut g = gcd(a, b);
        g = gcd(g, c);
        g = g.abs();
        a /= g;
        b /= g;
        c /= g;
        let res = Self {
            a: a.into(),
            b: b.into(),
            c: c.into(),
        };
        debug_assert!(res.a != OrdF64::ZERO || res.b != OrdF64::ZERO);
        res
    }

    pub fn on_line(&self, p: &Point) -> bool {
        (self.a * p.x + self.b * p.y + self.c).eq_with_default_eps(&OrdF64::ZERO)
    }

    pub fn intersect(&self, other: &Self) -> Option<Point> {
        let denom = self.b * other.a - other.b * self.a;
        if denom.eq_with_default_eps(&OrdF64::ZERO) {
            return None;
        }
        let y_num = other.c * self.a - self.c * other.a;
        let x_num = self.c * other.b - other.c * self.b;
        let res = Point::new(x_num / denom, y_num / denom);
        debug_assert!(
            self.abs_dist(&res)
                .eq_with_eps(&OrdF64::ZERO, OrdF64::SMALL_EPS),
            "line = {:?}, p = {:?}, dist = {:?}",
            self,
            res,
            self.abs_dist(&res)
        );
        debug_assert!(
            other
                .abs_dist(&res)
                .eq_with_eps(&OrdF64::ZERO, OrdF64::SMALL_EPS),
            "line = {:?}, p = {:?}, dist = {:?}",
            other,
            res,
            self.abs_dist(&res)
        );
        Some(res)
    }

    pub fn signed_dist(&self, p: &Point) -> OrdF64 {
        (self.a * p.x + self.b * p.y + self.c) / (self.a * self.a + self.b * self.b).sqrt()
    }

    pub fn abs_dist(&self, p: &Point) -> OrdF64 {
        self.signed_dist(p).abs()
    }

    pub fn abs_dist2(&self, p: &Point) -> OrdF64 {
        let z = self.a * p.x + self.b * p.y + self.c;
        z * z / (self.a * self.a + self.b * self.b)
    }

    pub fn closest_to_zero(&self) -> Point {
        let den = self.a * self.a + self.b * self.b;
        Point::new(-self.a * self.c / den, -self.b * self.c / den)
    }

    pub fn closest_on_line(&self, p: Point) -> Point {
        let den = self.a * self.a + self.b * self.b;
        let num = self.a * p.x + self.b * p.y + self.c;
        Point::new(p.x - self.a * num / den, p.y - self.b * num / den)
    }

    pub fn mirror(&self, p: Point) -> Point {
        let closest = self.closest_on_line(p);
        Point::new(OrdF64::TWO * closest.x - p.x, OrdF64::TWO * closest.y - p.y)
    }

    pub fn project(&self, p: Point) -> OrdF64 {
        (-self.b * p.x + self.a * p.y) / (self.a * self.a + self.b * self.b).sqrt()
    }
}
}
pub mod point {
use crate::f;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::input::Readable;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::iters::shifts::Shift;
use crate::algo_lib::misc::num_traits::Number;
use crate::algo_lib::misc::ord_f64::OrdF64;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Mul;
use std::ops::Sub;
use std::ops::SubAssign;

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Default)]
pub struct PointT<T: Number> {
    pub x: T,
    pub y: T,
}

impl<T: Ord + Number> Ord for PointT<T> {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.x.cmp(&other.x).then(self.y.cmp(&other.y))
    }
}

impl<T: Ord + Number> PartialOrd for PointT<T> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        self.cmp(other).into()
    }
}

impl<T: Number> PointT<T> {
    pub fn new<U: Into<T>>(x: U, y: U) -> Self {
        Self {
            x: x.into(),
            y: y.into(),
        }
    }

    pub fn dist2(&self, p2: &PointT<T>) -> T {
        let dx = self.x - p2.x;
        let dy = self.y - p2.y;
        dx * dx + dy * dy
    }

    pub fn side(&self) -> i32 {
        if self.y > T::ZERO || (self.y == T::ZERO && self.x >= T::ZERO) {
            return 0;
        }
        1
    }

    pub fn dist_manh(&self, p2: &PointT<T>) -> T {
        let dx = self.x - p2.x;
        let dy = self.y - p2.y;
        let dx_abs = if dx < T::ZERO { T::ZERO - dx } else { dx };
        let dy_abs = if dy < T::ZERO { T::ZERO - dy } else { dy };
        dx_abs + dy_abs
    }

    pub fn angle_to(&self, other: &PointT<T>) -> OrdF64
    where
        f64: From<T>,
    {
        let dy = other.y - self.y;
        let dx = other.x - self.x;
        OrdF64(f64::atan2(dy.into(), dx.into()))
    }

    pub fn swap_x_y(&self) -> Self {
        Self::new(self.y, self.x)
    }

    pub fn vect_mul(p1: &PointT<T>, p2: &PointT<T>, p3: &PointT<T>) -> T {
        (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x)
    }

    pub fn scal_mul(p1: &PointT<T>, p2: &PointT<T>, p3: &PointT<T>) -> T {
        Self::scal_mul2(&(*p2 - *p1), &(*p3 - *p1))
    }

    pub fn scal_mul2(p1: &PointT<T>, p2: &PointT<T>) -> T {
        p1.x * p2.x + p1.y * p2.y
    }

    pub fn vect_mul2(p1: &PointT<T>, p2: &PointT<T>) -> T {
        p1.x * p2.y - p1.y * p2.x
    }

    pub fn apply_shift(&self, shift: &Shift) -> Self {
        Self {
            x: self.x + T::from_i32(shift.dx),
            y: self.y + T::from_i32(shift.dy),
        }
    }

    pub fn shift(&self, dx: T, dy: T) -> Self {
        Self {
            x: self.x + dx,
            y: self.y + dy,
        }
    }

    pub fn scale(&self, coef: T) -> Self {
        Self {
            x: self.x * coef,
            y: self.y * coef,
        }
    }

    pub fn rotate_ccw(&self) -> Self {
        Self::new(T::ZERO - self.y, self.x)
    }

    pub const ZERO: PointT<T> = PointT {
        x: T::ZERO,
        y: T::ZERO,
    };

    pub fn conv_float(&self) -> PointT<OrdF64> {
        PointT::new(OrdF64(self.x.to_f64()), OrdF64(self.y.to_f64()))
    }
}

impl<T> Add for PointT<T>
where
    T: Number,
{
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        Self::new(self.x + rhs.x, self.y + rhs.y)
    }
}

impl<T> AddAssign for PointT<T>
where
    T: Number,
{
    fn add_assign(&mut self, rhs: Self) {
        self.x += rhs.x;
        self.y += rhs.y;
    }
}

impl<T> Sub for PointT<T>
where
    T: Number,
{
    type Output = Self;

    fn sub(self, rhs: Self) -> Self::Output {
        Self::new(self.x - rhs.x, self.y - rhs.y)
    }
}

impl<T> SubAssign for PointT<T>
where
    T: Number,
{
    fn sub_assign(&mut self, rhs: Self) {
        self.x -= rhs.x;
        self.y -= rhs.y;
    }
}

impl<T> Readable for PointT<T>
where
    T: Number + Readable,
{
    fn read(input: &mut Input) -> Self {
        let x = input.read();
        let y = input.read();
        Self { x, y }
    }
}

impl<T> Writable for PointT<T>
where
    T: Number + Writable,
{
    fn write(&self, output: &mut Output) {
        self.x.write(output);
        output.put(b' ');
        self.y.write(output);
    }
}

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct PointWithIdT<T: Number> {
    pub p: PointT<T>,
    id: u32,
}

impl<T> PointWithIdT<T>
where
    T: Number,
{
    pub fn new(p: PointT<T>, id: usize) -> Self {
        Self { p, id: id as u32 }
    }

    pub fn id(&self) -> usize {
        self.id as usize
    }
}

impl PointWithIdT<OrdF64> {
    pub fn dist(&self, other: &Self) -> OrdF64 {
        self.p.dist2(&other.p).sqrt()
    }
}

impl PointT<OrdF64> {
    pub fn rotate_ccw_angle(&self, angle: OrdF64) -> Self {
        let cos = f!(angle.0.cos());
        let sin = f!(angle.0.sin());
        let x = self.x * cos - self.y * sin;
        let y = self.y * cos + self.x * sin;
        Self { x, y }
    }
}

impl Mul<OrdF64> for PointT<OrdF64> {
    type Output = PointT<OrdF64>;

    fn mul(self, rhs: OrdF64) -> Self::Output {
        Self {
            x: self.x * rhs,
            y: self.y * rhs,
        }
    }
}
}
pub mod segment {
use std::cmp::Ordering;

use crate::algo_lib::geometry::direction::DirectionT;
use crate::algo_lib::geometry::line::Line;
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::geometry::segment_intersection::inside_bounding_box;
use crate::algo_lib::misc::num_traits::HasConstants;
use crate::algo_lib::misc::num_traits::Number;
use crate::algo_lib::misc::ord_f64::OrdF64;

#[derive(Copy, Clone, Debug)]
pub struct SegmentT<T>
where
    T: Number,
{
    pub from: PointT<T>,
    pub to: PointT<T>,
}

impl<T> SegmentT<T>
where
    T: Number + Ord,
{
    pub fn new(from: PointT<T>, to: PointT<T>) -> Self {
        Self { from, to }
    }

    pub fn dir(&self) -> DirectionT<T> {
        DirectionT::new(self.from, self.to)
    }

    ///
    /// 1 means "[p] is to the left from [self.from] -> [self.to] ray"
    /// 0 means "on the same line"
    ///
    pub fn to_the_left(&self, p: &PointT<T>) -> i32 {
        let v_mul = PointT::<T>::vect_mul(&self.from, &self.to, p);
        match v_mul.cmp(&T::ZERO) {
            Ordering::Less => -1,
            Ordering::Equal => 0,
            Ordering::Greater => 1,
        }
    }
}

impl SegmentT<OrdF64> {
    pub fn to_line(&self) -> Line {
        Line::new(&self.from, &self.to)
    }

    pub fn contains(&self, p: &PointT<OrdF64>) -> bool {
        // TODO: should use eps?
        inside_bounding_box(self, p) && PointT::vect_mul(&self.from, &self.to, p) == OrdF64::ZERO
    }

    pub fn len2(&self) -> OrdF64 {
        self.from.dist2(&self.to)
    }

    pub fn len(&self) -> OrdF64 {
        self.len2().sqrt()
    }
}
}
pub mod segment_intersection {
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::geometry::segment::SegmentT;
use crate::algo_lib::misc::ord_f64::OrdF64;
use std::cmp::max;
use std::cmp::min;

type Point = PointT<OrdF64>;
type Segment = SegmentT<OrdF64>;

fn inside_one_dim(range: (OrdF64, OrdF64), val: OrdF64) -> bool {
    min(range.0, range.1) - OrdF64::EPS <= val && val <= max(range.0, range.1) + OrdF64::EPS
}

pub fn inside_bounding_box(seg: &Segment, p: &Point) -> bool {
    inside_one_dim((seg.from.x, seg.to.x), p.x) && inside_one_dim((seg.from.y, seg.to.y), p.y)
}

pub fn segment_intersection(seg1: &Segment, seg2: &Segment) -> Option<Point> {
    seg1.to_line()
        .intersect(&seg2.to_line())
        .filter(|&inter| inside_bounding_box(seg1, &inter) && inside_bounding_box(seg2, &inter))
}
}
}
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;

pub struct Input {
    input: Box<dyn Read>,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_integer_fun {
    ($t:ident) => {
        #[allow(unused)]
        pub fn $t(&mut self) -> $t {
            self.read_integer()
        }
    };
}

impl Input {
    const DEFAULT_BUF_SIZE: usize = 4096;

    ///
    /// Using with stdin:
    /// ```no_run
    /// use algo_lib::io::input::Input;
    /// let stdin = std::io::stdin();
    /// let input = Input::new(Box::new(stdin));
    /// ```
    ///
    /// For read files use ``new_file`` instead.
    ///
    ///
    pub fn new(input: Box<dyn Read>) -> Self {
        Self {
            input,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_stdin() -> Self {
        let stdin = std::io::stdin();
        Self::new(Box::new(stdin))
    }

    pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new(Box::new(file))
    }

    pub fn new_with_size(input: Box<dyn Read>, buf_size: usize) -> Self {
        Self {
            input,
            buf: vec![0; buf_size],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new_with_size(Box::new(file), buf_size)
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            Some(self.buf[self.at])
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !char::from(b).is_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if char::from(c).is_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    pub fn has_more_elements(&mut self) -> bool {
        !self.is_exhausted()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.read());
        }
        res
    }

    pub fn string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.string());
        }
        res
    }

    pub fn read_line(&mut self) -> String {
        let mut res = String::new();
        while let Some(c) = self.get() {
            if c == b'\n' {
                break;
            }
            if c == b'\r' {
                if self.peek() == Some(b'\n') {
                    self.get();
                }
                break;
            }
            res.push(c.into());
        }
        res
    }

    #[allow(clippy::should_implement_trait)]
    pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
        InputIterator {
            input: self,
            phantom: Default::default(),
        }
    }

    fn read_integer<T: FromStr + Debug>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let res = self.read_string();
        res.parse::<T>().unwrap()
    }

    fn read_string(&mut self) -> String {
        match self.next_token() {
            None => {
                panic!("Input exhausted");
            }
            Some(res) => unsafe { String::from_utf8_unchecked(res) },
        }
    }

    pub fn string_as_string(&mut self) -> String {
        self.read_string()
    }

    pub fn string(&mut self) -> Vec<u8> {
        self.read_string().into_bytes()
    }

    fn read_char(&mut self) -> char {
        self.skip_whitespace();
        self.get().unwrap().into()
    }

    fn read_float(&mut self) -> f64 {
        self.read_string().parse().unwrap()
    }

    pub fn f64(&mut self) -> f64 {
        self.read_float()
    }

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }

    read_integer_fun!(i32);
    read_integer_fun!(i64);
    read_integer_fun!(i128);
    read_integer_fun!(u32);
    read_integer_fun!(u64);
    read_integer_fun!(usize);
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for String {
    fn read(input: &mut Input) -> Self {
        input.read_string()
    }
}

impl Readable for char {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl Readable for f64 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl Readable for f32 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.vec(size)
    }
}

pub struct InputIterator<T: Readable> {
    input: Input,
    phantom: PhantomData<T>,
}

impl<T: Readable> Iterator for InputIterator<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        self.input.skip_whitespace();
        self.input.peek().map(|_| self.input.read())
    }
}

macro_rules! read_integer {
    ($t:ident) => {
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.read_integer()
            }
        }
    };
}

read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;

pub struct Output {
    output: Box<dyn Write>,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
}

impl Output {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: false,
        }
    }

    pub fn new_stdout() -> Self {
        let stdout = std::io::stdout();
        Self::new(Box::new(stdout))
    }

    pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
        let file = std::fs::File::create(path).unwrap();
        Self::new(Box::new(file))
    }

    pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: true,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.at = 0;
            self.output.flush().expect("Couldn't flush output");
        }
    }

    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
    }

    pub fn println<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.put(b'\n');
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        for i in arg {
            i.write(self);
            self.put(b'\n');
        }
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }
}

impl Write for Output {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        if self.auto_flush {
            self.flush();
        }
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self[..].write(output);
    }
}

macro_rules! write_to_string {
    ($t:ident) => {
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    };
}

write_to_string!(u8);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(f64);

impl<T: Writable, U: Writable> Writable for (T, U) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
    }
}
}
}
pub mod iters {
pub mod shifts {
#[derive(Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
pub struct Shift {
    pub dx: i32,
    pub dy: i32,
}

impl Shift {
    pub fn rev(&self) -> Self {
        Self {
            dx: -self.dx,
            dy: -self.dy,
        }
    }
}

// x goes down
// y goes right
pub const SHIFT_DOWN: Shift = Shift { dx: 1, dy: 0 };
pub const SHIFT_UP: Shift = Shift { dx: -1, dy: 0 };
pub const SHIFT_RIGHT: Shift = Shift { dx: 0, dy: 1 };
pub const SHIFT_LEFT: Shift = Shift { dx: 0, dy: -1 };

pub const SHIFTS_4: [Shift; 4] = [SHIFT_DOWN, SHIFT_LEFT, SHIFT_UP, SHIFT_RIGHT];
pub const SHIFTS_8: [Shift; 8] = [
    SHIFT_DOWN,
    SHIFT_LEFT,
    SHIFT_UP,
    SHIFT_RIGHT,
    Shift { dx: -1, dy: -1 },
    Shift { dx: -1, dy: 1 },
    Shift { dx: 1, dy: -1 },
    Shift { dx: 1, dy: 1 },
];

pub const SHIFTS_9: [Shift; 9] = [
    SHIFT_DOWN,
    SHIFT_LEFT,
    SHIFT_UP,
    SHIFT_RIGHT,
    Shift { dx: -1, dy: -1 },
    Shift { dx: -1, dy: 1 },
    Shift { dx: 1, dy: -1 },
    Shift { dx: 1, dy: 1 },
    Shift { dx: 0, dy: 0 },
];

pub fn shift_by_nswe(c: u8) -> Shift {
    match c {
        b'S' | b's' => SHIFT_DOWN,
        b'N' | b'n' => SHIFT_UP,
        b'E' | b'e' => SHIFT_RIGHT,
        b'W' | b'w' => SHIFT_LEFT,
        _ => panic!("Unexpected direction!"),
    }
}

pub fn shift_by_uldr(c: u8) -> Shift {
    match c {
        b'D' | b'd' => SHIFT_DOWN,
        b'U' | b'u' => SHIFT_UP,
        b'R' | b'r' => SHIFT_RIGHT,
        b'L' | b'l' => SHIFT_LEFT,
        _ => panic!("Unexpected direction!"),
    }
}
}
}
pub mod math {
pub mod gcd {
use crate::algo_lib::misc::num_traits::Number;

#[allow(dead_code)]
fn extended_gcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    if a == 0 {
        *x = 0;
        *y = 1;
        return b;
    }
    let mut x1 = 0;
    let mut y1 = 0;
    let d = extended_gcd(b % a, a, &mut x1, &mut y1);
    *x = y1 - (b / a) * x1;
    *y = x1;
    d
}

///
///
/// Find any solution to equation A*x + B*y = C
///
/// Returns [false] if [C] is not divisible by gcd(A, B)
///
#[allow(dead_code)]
pub fn diophantine(a: i64, b: i64, c: i64, x0: &mut i64, y0: &mut i64, g: &mut i64) -> bool {
    *g = extended_gcd(a.abs(), b.abs(), x0, y0);
    if c % *g != 0 {
        return false;
    }
    *x0 *= c / *g;
    *y0 *= c / *g;
    if a < 0 {
        *x0 *= -1;
    }
    if b < 0 {
        *y0 *= -1;
    }
    true
}

#[allow(dead_code)]
pub fn gcd<T>(x: T, y: T) -> T
where
    T: Number + std::ops::Rem<Output = T>,
{
    if x == T::ZERO {
        y
    } else {
        gcd(y % x, x)
    }
}

pub fn lcm<T>(x: T, y: T) -> T
where
    T: Number + std::ops::Rem<Output = T>,
{
    x / gcd(x, y) * y
}
}
}
pub mod misc {
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
    ($first_val:expr, $($val:expr),+ $(,)?) => {
        eprint!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
        ($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
        eprintln!();
    };
    ($first_val:expr) => {
        eprintln!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val)
    };
}
}
pub mod gen_vector {
pub fn gen_vec<T>(n: usize, f: impl FnMut(usize) -> T) -> Vec<T> {
    (0..n).map(f).collect()
}
}
pub mod num_traits {
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;

pub trait HasConstants<T> {
    const MAX: T;
    const MIN: T;
    const ZERO: T;
    const ONE: T;
    const TWO: T;
}

pub trait ConvSimple<T> {
    fn from_i32(val: i32) -> T;
    fn to_i32(self) -> i32;
    fn to_f64(self) -> f64;
}

pub trait Signum {
    fn signum(&self) -> i32;
}

pub trait Number:
    Copy
    + Add<Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Mul<Output = Self>
    + MulAssign
    + Div<Output = Self>
    + DivAssign
    + PartialOrd
    + PartialEq
    + HasConstants<Self>
    + Default
    + Debug
    + Sized
    + ConvSimple<Self>
{
}

impl<
        T: Copy
            + Add<Output = Self>
            + AddAssign
            + Sub<Output = Self>
            + SubAssign
            + Mul<Output = Self>
            + MulAssign
            + Div<Output = Self>
            + DivAssign
            + PartialOrd
            + PartialEq
            + HasConstants<Self>
            + Default
            + Debug
            + Sized
            + ConvSimple<Self>,
    > Number for T
{
}

macro_rules! has_constants_impl {
    ($t: ident) => {
        impl HasConstants<$t> for $t {
            // TODO: remove `std` for new rust version..
            const MAX: $t = std::$t::MAX;
            const MIN: $t = std::$t::MIN;
            const ZERO: $t = 0;
            const ONE: $t = 1;
            const TWO: $t = 2;
        }

        impl ConvSimple<$t> for $t {
            fn from_i32(val: i32) -> $t {
                val as $t
            }

            fn to_i32(self) -> i32 {
                self as i32
            }

            fn to_f64(self) -> f64 {
                self as f64
            }
        }
    };
}

has_constants_impl!(i32);
has_constants_impl!(i64);
has_constants_impl!(i128);
has_constants_impl!(u32);
has_constants_impl!(u64);
has_constants_impl!(u128);
has_constants_impl!(usize);
has_constants_impl!(u8);

impl ConvSimple<Self> for f64 {
    fn from_i32(val: i32) -> Self {
        val as f64
    }

    fn to_i32(self) -> i32 {
        self as i32
    }

    fn to_f64(self) -> f64 {
        self
    }
}

impl HasConstants<Self> for f64 {
    const MAX: Self = Self::MAX;
    const MIN: Self = -Self::MAX;
    const ZERO: Self = 0.0;
    const ONE: Self = 1.0;
    const TWO: Self = 2.0;
}

impl<T: Number + Ord> Signum for T {
    fn signum(&self) -> i32 {
        match self.cmp(&T::ZERO) {
            Ordering::Greater => 1,
            Ordering::Less => -1,
            Ordering::Equal => 0,
        }
    }
}
}
pub mod ord_f64 {
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::input::Readable;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::misc::num_traits::ConvSimple;
use crate::algo_lib::misc::num_traits::HasConstants;
use std::cmp::min;
use std::cmp::Ordering;
use std::f64::consts::PI;
use std::fmt::Debug;
use std::fmt::Display;
use std::fmt::Formatter;
use std::io::Write;
use std::num::ParseFloatError;
use std::ops::Neg;
use std::ops::Rem;
use std::str::FromStr;

#[derive(PartialEq, Copy, Clone, Default)]
pub struct OrdF64(pub f64);

impl OrdF64 {
    pub const EPS: Self = Self(1e-9);
    pub const SMALL_EPS: Self = Self(1e-4);
    pub const PI: Self = Self(PI);

    pub fn abs(&self) -> Self {
        Self(self.0.abs())
    }

    pub fn eq_with_eps(&self, other: &Self, eps: Self) -> bool {
        let abs_diff = (*self - *other).abs();
        abs_diff <= eps || abs_diff <= min(self.abs(), other.abs()) * eps
    }

    pub fn eq_with_default_eps(&self, other: &Self) -> bool {
        self.eq_with_eps(other, Self::EPS)
    }

    pub fn sqrt(&self) -> Self {
        Self(self.0.sqrt())
    }

    pub fn powf(&self, n: f64) -> Self {
        Self(self.0.powf(n))
    }
}

impl Eq for OrdF64 {}

impl Ord for OrdF64 {
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

impl PartialOrd for OrdF64 {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        self.0.partial_cmp(&other.0)
    }
}

impl std::ops::Add for OrdF64 {
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        Self(self.0 + rhs.0)
    }
}

impl std::ops::AddAssign for OrdF64 {
    fn add_assign(&mut self, rhs: Self) {
        self.0 += rhs.0;
    }
}

impl std::ops::Sub for OrdF64 {
    type Output = Self;

    fn sub(self, rhs: Self) -> Self::Output {
        Self(self.0 - rhs.0)
    }
}

impl std::ops::SubAssign for OrdF64 {
    fn sub_assign(&mut self, rhs: Self) {
        self.0 -= rhs.0;
    }
}

impl std::ops::Mul for OrdF64 {
    type Output = Self;

    fn mul(self, rhs: Self) -> Self::Output {
        Self(self.0 * rhs.0)
    }
}

impl std::ops::MulAssign for OrdF64 {
    fn mul_assign(&mut self, rhs: Self) {
        self.0 *= rhs.0;
    }
}

impl std::ops::Div for OrdF64 {
    type Output = Self;

    fn div(self, rhs: Self) -> Self::Output {
        Self(self.0 / rhs.0)
    }
}

impl std::ops::DivAssign for OrdF64 {
    fn div_assign(&mut self, rhs: Self) {
        self.0 /= rhs.0;
    }
}

impl Neg for OrdF64 {
    type Output = Self;

    fn neg(self) -> Self::Output {
        Self(-self.0)
    }
}

impl Display for OrdF64 {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        Display::fmt(&self.0, f)
    }
}

impl Debug for OrdF64 {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        Debug::fmt(&self.0, f)
    }
}

impl Writable for OrdF64 {
    fn write(&self, output: &mut Output) {
        output.write_fmt(format_args!("{}", self.0)).unwrap();
    }
}

impl Readable for OrdF64 {
    fn read(input: &mut Input) -> Self {
        Self(input.read::<f64>())
    }
}

impl HasConstants<Self> for OrdF64 {
    const MAX: Self = Self(f64::MAX);
    const MIN: Self = Self(-f64::MAX);
    const ZERO: Self = Self(0.0);
    const ONE: Self = Self(1.0);
    const TWO: Self = Self(2.0);
}

impl ConvSimple<Self> for OrdF64 {
    fn from_i32(val: i32) -> Self {
        Self(val as f64)
    }

    fn to_i32(self) -> i32 {
        self.0 as i32
    }

    fn to_f64(self) -> f64 {
        self.0
    }
}

impl FromStr for OrdF64 {
    type Err = ParseFloatError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.parse::<f64>() {
            Ok(value) => Ok(Self(value)),
            Err(error) => Err(error),
        }
    }
}

impl From<OrdF64> for f64 {
    fn from(x: OrdF64) -> Self {
        x.0
    }
}

impl Rem for OrdF64 {
    type Output = Self;

    fn rem(self, rhs: Self) -> Self::Output {
        Self(self.0 % rhs.0)
    }
}

#[macro_export]
macro_rules! f {
    ($a:expr) => {
        OrdF64($a)
    };
}

impl From<usize> for OrdF64 {
    fn from(x: usize) -> Self {
        f!(x as f64)
    }
}

impl From<i32> for OrdF64 {
    fn from(x: i32) -> Self {
        f!(x as f64)
    }
}

impl From<i64> for OrdF64 {
    fn from(x: i64) -> Self {
        f!(x as f64)
    }
}

impl From<f64> for OrdF64 {
    fn from(x: f64) -> Self {
        f!(x)
    }
}
}
}
}
fn main() {
    let input = algo_lib::io::input::Input::new_stdin();
    let mut output = algo_lib::io::output::Output::new_stdout();
    crate::solution::run(input, output);
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 2184kb

input:

3
4 0
0 3
0 -1

output:

5
8
8.868185038797563
12.210024810881958

result:

ok 4 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 2248kb

input:

3
4 0
0 3
0 2

output:

5
5.366563145999495
6.111919138499425
6.782203304416629

result:

ok 4 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 2320kb

input:

3
4 0
0 3
0 1

output:

5
6.18465843842649
7.195223542744547
8.653439499294254

result:

ok 4 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 2100kb

input:

3
62 -12
-48 100
-45 -96

output:

196.0229578391266
312.04173783276065
326.27847771877623
452.8071237291108

result:

ok 4 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 2168kb

input:

3
90 99
-76 -57
99 84

output:

227.79815626997512
274.3523064577636
306.8917794770924
330.10518554643363

result:

ok 4 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 2108kb

input:

3
-67 22
-86 12
-81 -12

output:

36.76955262170048
39.563975005654065
50.91685591710603
72.27758551745076

result:

ok 4 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 2184kb

input:

3
71 -48
-81 2
-83 -44

output:

160.01249951175691
308.0567945675688
308.05679456756883
308.0567945675694

result:

ok 4 numbers

Test #8:

score: 0
Accepted
time: 0ms
memory: 2184kb

input:

3
44 -44
-31 -77
8 -98

output:

81.93900170248597
115.79266829979318
125.60604402992016
167.93649349697952

result:

ok 4 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 2144kb

input:

3
40 91
-42 90
-5 -99

output:

195.25624189766637
378.874266791999
378.87426679199905
378.87426679199905

result:

ok 4 numbers

Test #10:

score: 0
Accepted
time: 3ms
memory: 2204kb

input:

4
-10 -97
13 -98
90 50
42 97

output:

200.84820138602188
269.68734146533467
382.1660680404965
476.5992628303975
476.5992628303975

result:

ok 5 numbers

Test #11:

score: 0
Accepted
time: 3ms
memory: 2140kb

input:

4
39 89
-72 -94
87 -58
90 36

output:

214.03270778084362
413.7441466099239
413.7441466099239
502.9657182484804
595.0182126549054

result:

ok 5 numbers

Test #12:

score: 0
Accepted
time: 3ms
memory: 2180kb

input:

4
-6 -90
33 -75
4 97
-36 -69

output:

187.2671887971838
269.5494443973688
309.208057795515
364.70165807157
395.378287554407

result:

ok 5 numbers

Test #13:

score: 0
Accepted
time: 3ms
memory: 2108kb

input:

4
44 81
27 81
60 -57
83 3

output:

141.89080308462565
187.12271495993616
251.47668954805488
274.12765684348494
286.31951740573055

result:

ok 5 numbers

Test #14:

score: 0
Accepted
time: 3ms
memory: 2328kb

input:

4
96 -13
99 1
-67 -36
67 -37

output:

170.0735135169495
183.0854262490456
223.21210351724557
277.3791841974023
306.15039727040084

result:

ok 5 numbers

Test #15:

score: 0
Accepted
time: 3ms
memory: 2156kb

input:

4
-18 -98
80 -59
73 68
-78 -62

output:

199.25109786397667
378.32587882437474
378.32587882437474
512.6175438118577
557.3874576159105

result:

ok 5 numbers

Test #16:

score: 0
Accepted
time: 39ms
memory: 2096kb

input:

5
-90 41
-93 27
94 79
83 91
-44 94

output:

194.09533739891847
206.35552445442517
256.7313020008909
337.34690346234044
377.92916040834785
396.6629386605994

result:

ok 6 numbers

Test #17:

score: 0
Accepted
time: 34ms
memory: 2204kb

input:

5
78 -95
96 29
-95 34
-76 -82
64 -95

output:

215.80083410404146
379.47435182666504
555.0747894794863
584.0075273161519
640.7094383942896
693.1724916029176

result:

ok 6 numbers

Test #18:

score: 0
Accepted
time: 40ms
memory: 2184kb

input:

5
45 -26
38 62
-31 57
-40 -43
-13 -91

output:

161.27616066858735
297.82777299176104
329.1035322799193
455.41981978587694
496.8587774603126
600.6721130630663

result:

ok 6 numbers

Test #19:

score: 0
Accepted
time: 39ms
memory: 2148kb

input:

5
-28 78
-63 63
-85 30
-7 -80
61 -77

output:

187.01871564097536
342.3719736955784
437.2830840034143
525.9782779687853
704.0644536415579
704.0644536415579

result:

ok 6 numbers

Test #20:

score: 0
Accepted
time: 39ms
memory: 2384kb

input:

5
-20 91
-21 90
4 -99
18 -92
41 57

output:

191.50979087242746
232.3855250971103
282.2360792991933
389.3067011892582
404.07519594642906
477.05123579751216

result:

ok 6 numbers

Test #21:

score: -100
Wrong Answer
time: 41ms
memory: 2196kb

input:

5
40 -91
65 75
-50 -86
-48 -87
27 -96

output:

197.8534811419804
296.42293335198156
328.653687667103
385.63003625652226
404.17601704445536
480.9075454407723

result:

wrong answer 6th numbers differ - expected: '404.1760170', found: '480.9075454', error = '0.1898468'