QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#597316 | #9417. Palindromic Polygon | ucup-team296# | AC ✓ | 571ms | 6072kb | Rust | 37.6kb | 2024-09-28 17:33:50 | 2024-09-28 17:33:51 |
Judging History
answer
//
pub mod solution {
//{"name":"ucup_10_k","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""}],"testType":"multiNumber","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"ucup_10_k"}}}
use crate::algo_lib::collections::md_arr::arr2d::Arr2d;
use crate::algo_lib::collections::min_max::MinimMaxim;
use crate::algo_lib::geometry::point::Point;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::test_type::TaskType;
use crate::algo_lib::misc::test_type::TestType;
type PreCalc = ();
fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &mut PreCalc) {
let n = input.read_size();
let f = input.read_int_vec(n);
let pts = input.read_vec::<Point<i64>>(n);
let area = |i1: usize, i2: usize, i3: usize| -> i64 {
(pts[i1].x - pts[i3].x) * (pts[i2].y - pts[i1].y)
- (pts[i1].x - pts[i2].x) * (pts[i3].y - pts[i1].y)
};
let mut any = Arr2d::new(n, n, 0);
let mut same = Arr2d::new(n, n, 0);
let mut ans = 0;
for len in 1..n {
for i in 0..n {
let j = if i + len < n { i + len } else { i + len - n };
let mut cur_any = 0;
let mut cur_same = 0;
for k in i..i + len {
let k = if k < n { k } else { k - n };
let area = area(i, k, j);
cur_any.maxim(same[(i, k)] + area);
if f[j] == f[k] {
cur_same.maxim(any[(k, j)] + area);
}
}
any[(i, j)] = cur_any;
same[(i, j)] = cur_same;
if f[i] == f[j] {
ans.maxim(cur_any);
}
}
}
out.print_line(ans);
}
pub static TEST_TYPE: TestType = TestType::MultiNumber;
pub static TASK_TYPE: TaskType = TaskType::Classic;
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
let mut pre_calc = ();
match TEST_TYPE {
TestType::Single => solve(&mut input, &mut output, 1, &mut pre_calc),
TestType::MultiNumber => {
let t = input.read();
for i in 1..=t {
solve(&mut input, &mut output, i, &mut pre_calc);
}
}
TestType::MultiEof => {
let mut i = 1;
while input.peek().is_some() {
solve(&mut input, &mut output, i, &mut pre_calc);
i += 1;
}
}
}
output.flush();
match TASK_TYPE {
TaskType::Classic => {
input.skip_whitespace();
input.peek().is_none()
}
TaskType::Interactive => true,
}
}
}
pub mod algo_lib {
pub mod collections {
pub mod md_arr {
pub mod arr2d {
use crate::algo_lib::collections::slice_ext::legacy_fill::LegacyFill;
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 std::ops::Index;
use std::ops::IndexMut;
use std::ops::Range;
use std::slice::Iter;
use std::vec::IntoIter;
#[derive(Clone, Eq, PartialEq, Default)]
pub struct Arr2d<T> {
d1: usize,
d2: usize,
data: Vec<T>,
}
impl<T: Clone> Arr2d<T> {
pub fn new(d1: usize, d2: usize, value: T) -> Self {
Self {
d1,
d2,
data: vec![value; d1 * d2],
}
}
}
impl<T> Arr2d<T> {
pub fn generate<F>(d1: usize, d2: usize, mut gen: F) -> Self
where
F: FnMut(usize, usize) -> T,
{
let mut data = Vec::with_capacity(d1 * d2);
for i in 0usize..d1 {
for j in 0usize..d2 {
data.push(gen(i, j));
}
}
Self { d1, d2, data }
}
pub fn d1(&self) -> usize {
self.d1
}
pub fn d2(&self) -> usize {
self.d2
}
pub fn iter(&self) -> Iter<'_, T> {
self.data.iter()
}
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
self.data.iter_mut()
}
pub fn row(&self, row: usize) -> impl Iterator<Item = &T> {
assert!(row < self.d1);
self.data.iter().skip(row * self.d2).take(self.d2)
}
pub fn row_mut(&mut self, row: usize) -> impl Iterator<Item = &mut T> {
assert!(row < self.d1);
self.data.iter_mut().skip(row * self.d2).take(self.d2)
}
pub fn column(&self, col: usize) -> impl Iterator<Item = &T> {
assert!(col < self.d2);
self.data.iter().skip(col).step_by(self.d2)
}
pub fn column_mut(&mut self, col: usize) -> impl Iterator<Item = &mut T> {
assert!(col < self.d2);
self.data.iter_mut().skip(col).step_by(self.d2)
}
pub fn swap(&mut self, r1: usize, c1: usize, r2: usize, c2: usize) {
assert!(r1 < self.d1);
assert!(r2 < self.d1);
assert!(c1 < self.d2);
assert!(c2 < self.d2);
self.data.swap(r1 * self.d2 + c1, r2 * self.d2 + c2);
}
pub fn rows(&self) -> Range<usize> {
0..self.d1
}
pub fn cols(&self) -> Range<usize> {
0..self.d2
}
pub fn swap_rows(&mut self, r1: usize, r2: usize) {
assert!(r1 < self.d1);
assert!(r2 < self.d1);
if r1 == r2 {
return;
}
let (r1, r2) = (r1.min(r2), r1.max(r2));
let (head, tail) = self.data.split_at_mut(r2 * self.d2);
head[r1 * self.d2..(r1 + 1) * self.d2].swap_with_slice(&mut tail[..self.d2]);
}
}
impl<T: Clone> Arr2d<T> {
pub fn fill(&mut self, elem: T) {
self.data.legacy_fill(elem);
}
pub fn transpose(&self) -> Self {
Self::generate(self.d2, self.d1, |i, j| self[(j, i)].clone())
}
}
impl<T> Index<(usize, usize)> for Arr2d<T> {
type Output = T;
fn index(&self, (row, col): (usize, usize)) -> &Self::Output {
assert!(row < self.d1);
assert!(col < self.d2);
&self.data[self.d2 * row + col]
}
}
impl<T> Index<usize> for Arr2d<T> {
type Output = [T];
fn index(&self, index: usize) -> &Self::Output {
&self.data[self.d2 * index..self.d2 * (index + 1)]
}
}
impl<T> IndexMut<(usize, usize)> for Arr2d<T> {
fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut T {
assert!(row < self.d1);
assert!(col < self.d2);
&mut self.data[self.d2 * row + col]
}
}
impl<T> IndexMut<usize> for Arr2d<T> {
fn index_mut(&mut self, index: usize) -> &mut [T] {
&mut self.data[self.d2 * index..self.d2 * (index + 1)]
}
}
impl<T> AsRef<Vec<T>> for Arr2d<T> {
fn as_ref(&self) -> &Vec<T> {
&self.data
}
}
impl<T> AsMut<Vec<T>> for Arr2d<T> {
fn as_mut(&mut self) -> &mut Vec<T> {
&mut self.data
}
}
impl<T: Writable> Writable for Arr2d<T> {
fn write(&self, output: &mut Output) {
let mut at = 0usize;
for i in 0usize..self.d1 {
if i != 0 {
output.put(b'\n');
}
for j in 0usize..self.d2 {
if j != 0 {
output.put(b' ');
}
self.data[at].write(output);
at += 1;
}
}
}
}
impl<T> IntoIterator for Arr2d<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> Self::IntoIter {
self.data.into_iter()
}
}
impl<'a, T> IntoIterator for &'a Arr2d<T> {
type Item = &'a T;
type IntoIter = Iter<'a, T>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
pub trait Arr2dRead {
fn read_table<T: Readable>(&mut self, d1: usize, d2: usize) -> Arr2d<T>;
fn read_int_table(&mut self, d1: usize, d2: usize) -> Arr2d<i32>;
fn read_long_table(&mut self, d1: usize, d2: usize) -> Arr2d<i64>;
fn read_size_table(&mut self, d1: usize, d2: usize) -> Arr2d<usize>;
fn read_char_table(&mut self, d1: usize, d2: usize) -> Arr2d<char>;
}
impl Arr2dRead for Input<'_> {
fn read_table<T: Readable>(&mut self, d1: usize, d2: usize) -> Arr2d<T> {
Arr2d::generate(d1, d2, |_, _| self.read())
}
fn read_int_table(&mut self, d1: usize, d2: usize) -> Arr2d<i32> {
self.read_table(d1, d2)
}
fn read_long_table(&mut self, d1: usize, d2: usize) -> Arr2d<i64> {
self.read_table(d1, d2)
}
fn read_size_table(&mut self, d1: usize, d2: usize) -> Arr2d<usize> {
self.read_table(d1, d2)
}
fn read_char_table(&mut self, d1: usize, d2: usize) -> Arr2d<char> {
self.read_table(d1, d2)
}
}
pub trait Arr2dCharWrite {
fn print_table(&mut self, table: &Arr2d<char>);
}
impl Arr2dCharWrite for Output<'_> {
fn print_table(&mut self, table: &Arr2d<char>) {
let mut at = 0usize;
for _ in 0..table.d1 {
for _ in 0..table.d2 {
self.print(table.data[at]);
at += 1;
}
self.put(b'\n');
}
}
}
impl<T: Readable> Readable for Arr2d<T> {
fn read(input: &mut Input) -> Self {
let d1 = input.read();
let d2 = input.read();
input.read_table(d1, d2)
}
}
}
}
pub mod min_max {
pub trait MinimMaxim<Rhs = Self>: PartialOrd + Sized {
fn minim(&mut self, other: Rhs) -> bool;
fn maxim(&mut self, other: Rhs) -> bool;
}
impl<T: PartialOrd> MinimMaxim for T {
fn minim(&mut self, other: Self) -> bool {
if other < *self {
*self = other;
true
} else {
false
}
}
fn maxim(&mut self, other: Self) -> bool {
if other > *self {
*self = other;
true
} else {
false
}
}
}
impl<T: PartialOrd> MinimMaxim<T> for Option<T> {
fn minim(&mut self, other: T) -> bool {
match self {
None => {
*self = Some(other);
true
}
Some(v) => v.minim(other),
}
}
fn maxim(&mut self, other: T) -> bool {
match self {
None => {
*self = Some(other);
true
}
Some(v) => v.maxim(other),
}
}
}
}
pub mod slice_ext {
pub mod legacy_fill {
// 1.50
pub trait LegacyFill<T> {
fn legacy_fill(&mut self, val: T);
}
impl<T: Clone> LegacyFill<T> for [T] {
fn legacy_fill(&mut self, val: T) {
for el in self.iter_mut() {
*el = val.clone();
}
}
}
}
}
pub mod vec_ext {
pub mod default {
pub fn default_vec<T: Default>(len: usize) -> Vec<T> {
let mut v = Vec::with_capacity(len);
for _ in 0..len {
v.push(T::default());
}
v
}
}
}
}
pub mod geometry {
pub mod geometry_utils {
use crate::algo_lib::numbers::real::RealTrait;
pub fn canonize_angle<T: RealTrait + Copy>(angle: T) -> T {
canonize_angle_base(angle, T::zero() - T::PI)
}
pub fn canonize_angle_base<T: RealTrait + Copy>(angle: T, base: T) -> T {
let two = T::one() + T::one();
let mut angle = angle;
while angle < base - T::epsilon() {
angle += T::PI * two;
}
while angle > base + T::PI * two - T::epsilon() {
angle -= T::PI * two;
}
angle
}
}
pub mod line {
use crate::algo_lib::geometry::point::Point;
use crate::algo_lib::numbers::num_traits::algebra::Field;
use crate::algo_lib::numbers::num_traits::algebra::Ring;
use crate::algo_lib::numbers::real::RealTrait;
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct Line<T> {
pub a: T,
pub b: T,
pub c: T,
}
impl<T> Line<T> {
pub fn new(a: T, b: T, c: T) -> Self {
Self { a, b, c }
}
}
impl<T: Ring + Copy> Line<T> {
pub fn value(&self, p: Point<T>) -> T {
self.a * p.x + self.b * p.y + self.c
}
pub fn parallel(&self, p: Point<T>) -> Line<T> {
Line::new(self.a, self.b, T::zero() - self.a * p.x - self.b * p.y)
}
pub fn perpendicular(&self, p: Point<T>) -> Line<T> {
Line::new(
T::zero() - self.b,
self.a,
T::zero() + self.b * p.x - self.a * p.y,
)
}
}
impl<T: Ring + Copy> Line<T> {
pub fn is_parallel(&self, other: Line<T>) -> bool {
self.a * other.b == self.b * other.a
}
pub fn is_perpendicular(&self, other: Line<T>) -> bool {
self.a * other.a + self.b * other.b == T::zero()
}
}
impl<T: Field + Copy> Line<T> {
pub fn intersect(&self, other: Line<T>) -> Point<T> {
let det = self.a * other.b - other.a * self.b;
let x = (self.b * other.c - other.b * self.c) / det;
let y = (other.a * self.c - self.a * other.c) / det;
Point::new(x, y)
}
pub fn square_dist_point(&self, p: Point<T>) -> T {
let val = self.value(p);
val * val / (self.a * self.a + self.b * self.b)
}
}
impl<T: Ring + Copy + PartialEq> Line<T> {
pub fn contains(&self, p: Point<T>) -> bool {
self.value(p) == T::zero()
}
}
impl<T: RealTrait + Copy> Line<T> {
pub fn new_real(a: T, b: T, c: T) -> Self {
let h = T::hypot(a, b);
Self {
a: a / h,
b: b / h,
c: c / h,
}
}
pub fn dist_point(&self, p: Point<T>) -> T {
self.square_dist_point(p).sqrt()
}
pub fn contains_real(&self, p: Point<T>) -> bool {
self.dist_point(p) < T::epsilon()
}
pub fn is_parallel_real(&self, other: Line<T>) -> bool {
(self.a * other.b - self.b * other.a).abs() < T::epsilon()
}
pub fn is_perpendicular_real(&self, other: Line<T>) -> bool {
(self.a * other.a + self.b * other.b).abs() < T::epsilon()
}
pub fn canonize(&mut self) {
let h = T::hypot(self.a, self.b);
self.a /= h;
self.b /= h;
self.c /= h;
}
}
}
pub mod point {
use crate::algo_lib::geometry::geometry_utils::canonize_angle;
use crate::algo_lib::geometry::line::Line;
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::numbers::num_traits::algebra::Ring;
use crate::algo_lib::numbers::num_traits::algebra::Zero;
use crate::algo_lib::numbers::real::RealTrait;
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;
#[derive(Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
pub struct Point<T> {
pub x: T,
pub y: T,
}
impl<T> Point<T> {
pub fn new(x: T, y: T) -> Self {
Self { x, y }
}
}
impl<T: Zero> Point<T> {
pub fn origin() -> Self {
Self::new(T::zero(), T::zero())
}
}
impl<T: Ring + Copy> Point<T> {
pub fn square_dist_point(&self, p: Self) -> T {
let delta = *self - p;
delta * delta
}
pub fn line(&self, p: Self) -> Line<T> {
let a = self.y - p.y;
let b = p.x - self.x;
Line::new(a, b, T::zero() - a * self.x - b * self.y)
}
}
impl<T: RealTrait + Copy> Point<T> {
pub fn from_polar(r: T, alpha: T) -> Self {
Self::new(r * alpha.cos(), r * alpha.sin())
}
pub fn dist_point(&self, p: Self) -> T {
self.square_dist_point(p).sqrt()
}
pub fn same(&self, p: Self) -> bool {
(self.x - p.x).abs() < T::epsilon() && (self.y - p.y).abs() < T::epsilon()
}
pub fn angle(&self) -> T {
T::atan2(self.y, self.x)
}
pub fn angle_to(&self, p: Self) -> T {
canonize_angle(p.angle() - self.angle()).abs()
}
}
impl<T: AddAssign> Add for Point<T> {
type Output = Point<T>;
fn add(mut self, rhs: Self) -> Self::Output {
self += rhs;
self
}
}
impl<T: AddAssign> AddAssign for Point<T> {
fn add_assign(&mut self, rhs: Self) {
self.x += rhs.x;
self.y += rhs.y;
}
}
impl<T: SubAssign> Sub for Point<T> {
type Output = Point<T>;
fn sub(mut self, rhs: Self) -> Self::Output {
self -= rhs;
self
}
}
impl<T: SubAssign> SubAssign for Point<T> {
fn sub_assign(&mut self, rhs: Self) {
self.x -= rhs.x;
self.y -= rhs.y;
}
}
impl<T: MulAssign + Copy> MulAssign<T> for Point<T> {
fn mul_assign(&mut self, rhs: T) {
self.x *= rhs;
self.y *= rhs;
}
}
impl<T: MulAssign + Copy> Mul<T> for Point<T> {
type Output = Point<T>;
fn mul(mut self, rhs: T) -> Self::Output {
self *= rhs;
self
}
}
impl<T: DivAssign + Copy> DivAssign<T> for Point<T> {
fn div_assign(&mut self, rhs: T) {
self.x /= rhs;
self.y /= rhs;
}
}
impl<T: DivAssign + Copy> Div<T> for Point<T> {
type Output = Point<T>;
fn div(mut self, rhs: T) -> Self::Output {
self /= rhs;
self
}
}
impl<T: Mul<Output = U>, U: Add> Mul for Point<T> {
type Output = U::Output;
fn mul(self, rhs: Self) -> Self::Output {
self.x * rhs.x + self.y * rhs.y
}
}
impl<T: Writable> Writable for Point<T> {
fn write(&self, output: &mut Output) {
self.x.write(output);
' '.write(output);
self.y.write(output);
}
}
impl<T: Readable> Readable for Point<T> {
fn read(input: &mut Input) -> Self {
let x = input.read();
let y = input.read();
Self::new(x, y)
}
}
}
}
pub mod io {
pub mod input {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::io::Read;
pub struct Input<'s> {
input: &'s mut dyn Read,
buf: Vec<u8>,
at: usize,
buf_read: usize,
}
macro_rules! read_impl {
($t: ty, $read_name: ident, $read_vec_name: ident) => {
pub fn $read_name(&mut self) -> $t {
self.read()
}
pub fn $read_vec_name(&mut self, len: usize) -> Vec<$t> {
self.read_vec(len)
}
};
($t: ty, $read_name: ident, $read_vec_name: ident, $read_pair_vec_name: ident) => {
read_impl!($t, $read_name, $read_vec_name);
pub fn $read_pair_vec_name(&mut self, len: usize) -> Vec<($t, $t)> {
self.read_vec(len)
}
};
}
impl<'s> Input<'s> {
const DEFAULT_BUF_SIZE: usize = 4096;
pub fn new(input: &'s mut dyn Read) -> Self {
Self {
input,
buf: default_vec(Self::DEFAULT_BUF_SIZE),
at: 0,
buf_read: 0,
}
}
pub fn new_with_size(input: &'s mut dyn Read, buf_size: usize) -> Self {
Self {
input,
buf: default_vec(buf_size),
at: 0,
buf_read: 0,
}
}
pub fn get(&mut self) -> Option<u8> {
if self.refill_buffer() {
let res = self.buf[self.at];
self.at += 1;
if res == b'\r' {
if self.refill_buffer() && self.buf[self.at] == b'\n' {
self.at += 1;
}
return Some(b'\n');
}
Some(res)
} else {
None
}
}
pub fn peek(&mut self) -> Option<u8> {
if self.refill_buffer() {
let res = self.buf[self.at];
Some(if res == b'\r' { b'\n' } else { res })
} else {
None
}
}
pub fn skip_whitespace(&mut self) {
while let Some(b) = self.peek() {
if !b.is_ascii_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 c.is_ascii_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()
}
//noinspection RsSelfConvention
pub fn is_empty(&mut self) -> bool {
self.skip_whitespace();
self.is_exhausted()
}
pub fn read<T: Readable>(&mut self) -> T {
T::read(self)
}
pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
let mut res = Vec::with_capacity(size);
for _ in 0..size {
res.push(self.read());
}
res
}
pub fn read_char(&mut self) -> char {
self.skip_whitespace();
self.get().unwrap().into()
}
read_impl!(u32, read_unsigned, read_unsigned_vec);
read_impl!(u64, read_u64, read_u64_vec);
read_impl!(usize, read_size, read_size_vec, read_size_pair_vec);
read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
read_impl!(i128, read_i128, read_i128_vec);
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
}
}
}
pub trait Readable {
fn read(input: &mut Input) -> Self;
}
impl Readable for char {
fn read(input: &mut Input) -> Self {
input.read_char()
}
}
impl<T: Readable> Readable for Vec<T> {
fn read(input: &mut Input) -> Self {
let size = input.read();
input.read_vec(size)
}
}
macro_rules! read_integer {
($($t:ident)+) => {$(
impl Readable for $t {
fn read(input: &mut Input) -> Self {
input.skip_whitespace();
let mut c = input.get().unwrap();
let sgn = match c {
b'-' => {
c = input.get().unwrap();
true
}
b'+' => {
c = input.get().unwrap();
false
}
_ => false,
};
let mut res = 0;
loop {
assert!(c.is_ascii_digit());
res *= 10;
let d = (c - b'0') as $t;
if sgn {
res -= d;
} else {
res += d;
}
match input.get() {
None => break,
Some(ch) => {
if ch.is_ascii_whitespace() {
break;
} else {
c = ch;
}
}
}
}
res
}
}
)+};
}
read_integer!(i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize);
macro_rules! tuple_readable {
($($name:ident)+) => {
impl<$($name: Readable), +> Readable for ($($name,)+) {
fn read(input: &mut Input) -> Self {
($($name::read(input),)+)
}
}
}
}
tuple_readable! {T}
tuple_readable! {T U}
tuple_readable! {T U V}
tuple_readable! {T U V X}
tuple_readable! {T U V X Y}
tuple_readable! {T U V X Y Z}
tuple_readable! {T U V X Y Z A}
tuple_readable! {T U V X Y Z A B}
tuple_readable! {T U V X Y Z A B C}
tuple_readable! {T U V X Y Z A B C D}
tuple_readable! {T U V X Y Z A B C D E}
tuple_readable! {T U V X Y Z A B C D E F}
impl Read for Input<'_> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
if self.at == self.buf_read {
self.input.read(buf)
} else {
let mut i = 0;
while i < buf.len() && self.at < self.buf_read {
buf[i] = self.buf[self.at];
i += 1;
self.at += 1;
}
Ok(i)
}
}
}
}
pub mod output {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::cmp::Reverse;
use std::io::stderr;
use std::io::Stderr;
use std::io::Write;
#[derive(Copy, Clone)]
pub enum BoolOutput {
YesNo,
YesNoCaps,
PossibleImpossible,
Custom(&'static str, &'static str),
}
impl BoolOutput {
pub fn output(&self, output: &mut Output, val: bool) {
(if val { self.yes() } else { self.no() }).write(output);
}
fn yes(&self) -> &str {
match self {
BoolOutput::YesNo => "Yes",
BoolOutput::YesNoCaps => "YES",
BoolOutput::PossibleImpossible => "Possible",
BoolOutput::Custom(yes, _) => yes,
}
}
fn no(&self) -> &str {
match self {
BoolOutput::YesNo => "No",
BoolOutput::YesNoCaps => "NO",
BoolOutput::PossibleImpossible => "Impossible",
BoolOutput::Custom(_, no) => no,
}
}
}
pub struct Output<'s> {
output: &'s mut dyn Write,
buf: Vec<u8>,
at: usize,
auto_flush: bool,
bool_output: BoolOutput,
}
impl<'s> Output<'s> {
const DEFAULT_BUF_SIZE: usize = 4096;
pub fn new(output: &'s mut dyn Write) -> Self {
Self {
output,
buf: default_vec(Self::DEFAULT_BUF_SIZE),
at: 0,
auto_flush: false,
bool_output: BoolOutput::YesNoCaps,
}
}
pub fn new_with_auto_flush(output: &'s mut dyn Write) -> Self {
Self {
output,
buf: default_vec(Self::DEFAULT_BUF_SIZE),
at: 0,
auto_flush: true,
bool_output: BoolOutput::YesNoCaps,
}
}
pub fn flush(&mut self) {
if self.at != 0 {
self.output.write_all(&self.buf[..self.at]).unwrap();
self.output.flush().unwrap();
self.at = 0;
}
}
pub fn print<T: Writable>(&mut self, s: T) {
s.write(self);
self.maybe_flush();
}
pub fn print_line<T: Writable>(&mut self, s: T) {
self.print(s);
self.put(b'\n');
self.maybe_flush();
}
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]) {
self.print_per_line_iter(arg.iter());
}
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_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
self.print_iter(iter);
self.put(b'\n');
}
pub fn print_per_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
for e in iter {
e.write(self);
self.put(b'\n');
}
}
pub fn set_bool_output(&mut self, bool_output: BoolOutput) {
self.bool_output = bool_output;
}
}
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;
}
self.maybe_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(self.iter());
}
}
impl<T: Writable, const N: usize> Writable for [T; N] {
fn write(&self, output: &mut Output) {
output.print_iter(self.iter());
}
}
impl<T: Writable + ?Sized> Writable for &T {
fn write(&self, output: &mut Output) {
T::write(self, output)
}
}
impl<T: Writable> Writable for Vec<T> {
fn write(&self, output: &mut Output) {
self.as_slice().write(output);
}
}
impl Writable for () {
fn write(&self, _output: &mut 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 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
macro_rules! tuple_writable {
($name0:ident $($name:ident: $id:tt )*) => {
impl<$name0: Writable, $($name: Writable,)*> Writable for ($name0, $($name,)*) {
fn write(&self, out: &mut Output) {
self.0.write(out);
$(
out.put(b' ');
self.$id.write(out);
)*
}
}
}
}
tuple_writable! {T}
tuple_writable! {T U:1}
tuple_writable! {T U:1 V:2}
tuple_writable! {T U:1 V:2 X:3}
tuple_writable! {T U:1 V:2 X:3 Y:4}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6 B:7}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6 B:7 C:8}
impl<T: Writable> Writable for Option<T> {
fn write(&self, output: &mut Output) {
match self {
None => (-1).write(output),
Some(t) => t.write(output),
}
}
}
impl Writable for bool {
fn write(&self, output: &mut Output) {
let bool_output = output.bool_output;
bool_output.output(output, *self)
}
}
impl<T: Writable> Writable for Reverse<T> {
fn write(&self, output: &mut Output) {
self.0.write(output);
}
}
static mut ERR: Option<Stderr> = None;
pub fn err() -> Output<'static> {
unsafe {
if ERR.is_none() {
ERR = Some(stderr());
}
Output::new_with_auto_flush(ERR.as_mut().unwrap())
}
}
}
}
pub mod misc {
pub mod test_type {
pub enum TestType {
Single,
MultiNumber,
MultiEof,
}
pub enum TaskType {
Classic,
Interactive,
}
}
}
pub mod numbers {
pub mod num_traits {
pub mod algebra {
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
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::Neg;
use std::ops::Rem;
use std::ops::RemAssign;
use std::ops::Sub;
use std::ops::SubAssign;
pub trait Zero {
fn zero() -> Self;
}
pub trait One {
fn one() -> Self;
}
pub trait AdditionMonoid: Add<Output = Self> + AddAssign + Zero + Eq + Sized {}
impl<T: Add<Output = Self> + AddAssign + Zero + Eq> AdditionMonoid for T {}
pub trait AdditionMonoidWithSub: AdditionMonoid + Sub<Output = Self> + SubAssign {}
impl<T: AdditionMonoid + Sub<Output = Self> + SubAssign> AdditionMonoidWithSub for T {}
pub trait AdditionGroup: AdditionMonoidWithSub + Neg<Output = Self> {}
impl<T: AdditionMonoidWithSub + Neg<Output = Self>> AdditionGroup for T {}
pub trait MultiplicationMonoid: Mul<Output = Self> + MulAssign + One + Eq + Sized {}
impl<T: Mul<Output = Self> + MulAssign + One + Eq> MultiplicationMonoid for T {}
pub trait IntegerMultiplicationMonoid:
MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign + RemAssign
{
}
impl<T: MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign + RemAssign>
IntegerMultiplicationMonoid for T
{
}
pub trait MultiplicationGroup:
MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>
{
}
impl<T: MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>>
MultiplicationGroup for T
{
}
pub trait SemiRing: AdditionMonoid + MultiplicationMonoid {}
impl<T: AdditionMonoid + MultiplicationMonoid> SemiRing for T {}
pub trait SemiRingWithSub: AdditionMonoidWithSub + SemiRing {}
impl<T: AdditionMonoidWithSub + SemiRing> SemiRingWithSub for T {}
pub trait Ring: SemiRing + AdditionGroup {}
impl<T: SemiRing + AdditionGroup> Ring for T {}
pub trait IntegerSemiRing: SemiRing + IntegerMultiplicationMonoid {}
impl<T: SemiRing + IntegerMultiplicationMonoid> IntegerSemiRing for T {}
pub trait IntegerSemiRingWithSub: SemiRingWithSub + IntegerSemiRing {}
impl<T: SemiRingWithSub + IntegerSemiRing> IntegerSemiRingWithSub for T {}
pub trait IntegerRing: IntegerSemiRing + Ring {}
impl<T: IntegerSemiRing + Ring> IntegerRing for T {}
pub trait Field: Ring + MultiplicationGroup {}
impl<T: Ring + MultiplicationGroup> Field for T {}
macro_rules! zero_one_integer_impl {
($($t: ident)+) => {$(
impl Zero for $t {
fn zero() -> Self {
0
}
}
impl One for $t {
fn one() -> Self {
1
}
}
)+};
}
zero_one_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);
}
pub mod invertible {
pub trait Invertible {
type Output;
fn inv(&self) -> Option<Self::Output>;
}
}
}
pub mod real {
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::numbers::num_traits::algebra::Field;
use crate::algo_lib::numbers::num_traits::algebra::One;
use crate::algo_lib::numbers::num_traits::algebra::Zero;
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
use std::cmp::Ordering;
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::Neg;
use std::ops::Sub;
use std::ops::SubAssign;
pub trait RealTrait: Ord + Field {
const PI: Self;
fn abs(&self) -> Self;
fn sqrt(&self) -> Self;
fn sin(&self) -> Self;
fn cos(&self) -> Self;
fn tan(&self) -> Self;
fn hypot(x: Self, y: Self) -> Self;
fn atan2(y: Self, x: Self) -> Self;
fn epsilon() -> Self;
fn set_epsilon(eps: Self);
}
#[derive(Copy, Clone, PartialOrd, PartialEq, Debug, Default)]
pub struct Real(pub f64);
impl Real {
pub fn round(&self) -> i64 {
self.0.round() as i64
}
}
impl Eq for Real {}
#[allow(clippy::derive_ord_xor_partial_ord)]
impl Ord for Real {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap()
}
}
impl AddAssign for Real {
fn add_assign(&mut self, rhs: Self) {
self.0 += rhs.0;
}
}
impl Add for Real {
type Output = Self;
fn add(mut self, rhs: Self) -> Self::Output {
self += rhs;
self
}
}
impl SubAssign for Real {
fn sub_assign(&mut self, rhs: Self) {
self.0 -= rhs.0;
}
}
impl Sub for Real {
type Output = Self;
fn sub(mut self, rhs: Self) -> Self::Output {
self -= rhs;
self
}
}
impl MulAssign for Real {
fn mul_assign(&mut self, rhs: Self) {
self.0 *= rhs.0;
}
}
impl Mul for Real {
type Output = Self;
fn mul(mut self, rhs: Self) -> Self::Output {
self.0 *= rhs.0;
self
}
}
impl DivAssign for Real {
fn div_assign(&mut self, rhs: Self) {
self.0 /= rhs.0;
}
}
impl Div for Real {
type Output = Self;
fn div(mut self, rhs: Self) -> Self::Output {
self /= rhs;
self
}
}
impl Neg for Real {
type Output = Self;
fn neg(self) -> Self::Output {
Self(-self.0)
}
}
impl Zero for Real {
fn zero() -> Self {
Self(0.0)
}
}
impl One for Real {
fn one() -> Self {
Self(1.0)
}
}
static mut EPSILON: Real = Real(1e-9);
impl RealTrait for Real {
const PI: Self = Self(std::f64::consts::PI);
fn abs(&self) -> Self {
Self(self.0.abs())
}
fn sqrt(&self) -> Self {
Self(self.0.sqrt())
}
fn sin(&self) -> Self {
Self(self.0.sin())
}
fn cos(&self) -> Self {
Self(self.0.cos())
}
fn tan(&self) -> Self {
Self(self.0.tan())
}
fn hypot(x: Self, y: Self) -> Self {
Self(f64::hypot(x.0, y.0))
}
fn atan2(y: Self, x: Self) -> Self {
Self(f64::atan2(y.0, x.0))
}
fn epsilon() -> Self {
unsafe { EPSILON }
}
fn set_epsilon(eps: Self) {
unsafe {
EPSILON = eps;
}
}
}
impl Invertible for Real {
type Output = Self;
fn inv(&self) -> Option<Self::Output> {
if self == &Self::zero() {
None
} else {
Some(Self(1.0 / self.0))
}
}
}
impl Readable for Real {
fn read(input: &mut Input) -> Self {
Self(
String::from_utf8(input.next_token().unwrap())
.unwrap()
.parse()
.unwrap(),
)
}
}
impl Writable for Real {
fn write(&self, output: &mut Output) {
self.0.to_string().write(output);
}
}
pub trait RealReader {
fn read_real(&mut self) -> Real;
fn read_real_vec(&mut self, n: usize) -> Vec<Real>;
}
impl RealReader for Input<'_> {
fn read_real(&mut self) -> Real {
self.read()
}
fn read_real_vec(&mut self, n: usize) -> Vec<Real> {
self.read_vec(n)
}
}
pub trait IntoReal {
fn into_real(self) -> Real;
}
macro_rules! into_real {
($($t: ident)+) => {$(
impl IntoReal for $t {
fn into_real(self) -> Real {
Real(self as f64)
}
}
)+};
}
into_real!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize f64);
}
}
}
fn main() {
let mut sin = std::io::stdin();
let input = algo_lib::io::input::Input::new(&mut sin);
let mut stdout = std::io::stdout();
let output = algo_lib::io::output::Output::new(&mut stdout);
solution::run(input, output);
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 2128kb
input:
3 8 2 4 2 4 3 4 5 3 2 3 0 6 -3 3 -3 0 -2 -3 1 -5 3 -3 4 0 3 1 2 3 0 0 1 0 0 1 3 1 1 1 0 0 1 0 0 1
output:
84 0 1
result:
ok 3 number(s): "84 0 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 2104kb
input:
1 4 1000000000 1000000000 1000000000 1000000000 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
output:
8000000000000000000
result:
ok 1 number(s): "8000000000000000000"
Test #3:
score: 0
Accepted
time: 0ms
memory: 2196kb
input:
129 10 604040473 604040473 287094217 682965575 70435786 287094217 604040473 287094217 682965575 92620053 -193 -184 -200 -200 -125 -169 -120 -157 -120 -145 -124 -139 -137 -136 -155 -149 -172 -163 -187 -177 5 346787871 346787871 113397429 113397429 346787871 -173 -181 -186 -166 -200 -195 -194 -200 -17...
output:
3857 1068 877 516 2668 3559 1165 3468 560 925 3502 696 3824 1746 2970 1826 613 2221 1130 4677 1900 1646 564 273 3203 6572 1070 3330 1024 765 142 3038 1615 9445 2122 320 1741 2561 1145 480 2094 5119 5458 2446 3929 2249 4378 4927 2356 1473 3152 1574 1990 1609 3367 2298 1459 2663 2617 2298 4048 215 546...
result:
ok 129 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 2172kb
input:
135 5 1 1 2 113253381 2 -187 -200 -185 -199 -172 -161 -192 -163 -200 -181 6 2 1 558119535 2 681168219 1 -159 -157 -200 -181 -197 -188 -190 -200 -179 -187 -164 -169 9 330122537 1 43508877 1 330122537 2 43508877 43508877 2 -115 -171 -127 -160 -140 -158 -153 -161 -170 -166 -190 -181 -200 -200 -126 -197...
output:
1199 1019 4995 993 374 2202 5999 2738 1610 287 2402 2421 1968 2253 889 2109 3594 1369 660 3823 1039 779 1068 1961 793 4749 906 1528 834 1125 244 532 1943 999 2279 274 1928 1969 3195 4189 762 1266 1330 6496 550 1452 2392 5402 246 1504 1603 1190 2002 2010 3855 5341 1096 730 4077 1005 368 2383 2465 278...
result:
ok 135 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 2096kb
input:
68 18 177729849 694994462 698865345 342457858 192803483 342457858 666388583 192803483 981906585 981906585 477960944 666388583 477960944 666388583 279990638 192803483 666388583 378306063 -247299689 -596018085 -257763469 -530664858 -307204843 -477869906 -830737754 -587840234 -915132692 -619194354 -100...
output:
454110023930570607 183756804328850070 298315022228123202 307512523943663260 356398611422117225 175693541183498183 85435294912017589 90055534959464621 470255288030458232 72285943569225582 93246116205839344 204734350926653941 181050899065321759 92595596931349298 252462643584630356 170478369910592368 2...
result:
ok 68 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 2088kb
input:
68 17 4 5 364570994 3 364570994 922037103 1 2 1 3 4 922037103 348120378 922774606 2 5 348120378 -944527911 -585310186 -985388783 -648105509 -996957301 -724274531 -1000000000 -776231334 -987660458 -849026993 -956240043 -910614062 -921236523 -949464303 -824975533 -1000000000 -758560856 -997163831 -685...
output:
283257114140518651 196218877050842110 222494863055424896 205446281561853782 250005106663316430 97542520284278361 366125469664341547 45201313979184996 302406140775158311 273846619401894473 114076427182578290 296093289576963628 314427730122999682 275016401751244176 113458042513568150 65331043997675878...
result:
ok 68 numbers
Test #7:
score: 0
Accepted
time: 63ms
memory: 2844kb
input:
5 200 609999526 472639833 217024831 181719265 607443350 247865634 182637039 952698029 667998662 552937384 309920961 395554742 529168804 633125523 572946770 964103704 809297865 675769477 8628527 954614525 607443350 402709616 933276333 156118214 382882490 982120770 8449875 613209070 635469591 90592427...
output:
26672937937698 21734491556698 26790824844133 30739464810342 25766825658360
result:
ok 5 number(s): "26672937937698 21734491556698 ...3 30739464810342 25766825658360"
Test #8:
score: 0
Accepted
time: 68ms
memory: 2676kb
input:
5 200 492204292 199500284 956414792 947905664 397147741 584603063 477504704 67732501 947905664 168522928 23355651 717940721 618420996 23355651 850784605 928119758 717940721 375517624 745458203 790993066 558764624 889247289 690761448 654316570 720267356 380473009 294135686 730680716 871352642 7131338...
output:
25179077707847 24610803287778 27879482074960 26586509092648 23860637721112
result:
ok 5 number(s): "25179077707847 24610803287778 ...0 26586509092648 23860637721112"
Test #9:
score: 0
Accepted
time: 68ms
memory: 2708kb
input:
5 200 84 35 20 33 36 78 24 47 5 18 90 100 48 99 17 86 92 42 22 22 91 15 16 34 61 2 52 72 31 71 24 67 10 64 72 81 56 47 34 58 75 46 59 85 27 14 14 83 30 42 13 89 38 52 51 66 44 51 62 41 28 40 12 79 23 56 81 8 60 69 65 68 26 96 55 68 46 70 1 21 84 44 62 4 23 99 69 18 35 54 37 19 39 93 48 8 43 53 16 93...
output:
25742598865692 23940201061139 21774320032543 29925923291252 25943299932354
result:
ok 5 number(s): "25742598865692 23940201061139 ...3 29925923291252 25943299932354"
Test #10:
score: 0
Accepted
time: 68ms
memory: 2688kb
input:
5 200 30 1 9 6 855627481 44 807240211 19 328678825 43 2 611193007 21 1 17357465 777452512 296168618 293501368 41887972 16 460434285 25 17 2 820070575 32 49 11 50 7 876136756 48 167436795 18 44 9 32 34 492450178 92584206 117799001 753835505 447351438 293501368 14 45 17357465 47 419370691 820070575 8 ...
output:
25588520303771 24556295312210 22684955350359 25702614992989 26005004619374
result:
ok 5 number(s): "25588520303771 24556295312210 ...9 25702614992989 26005004619374"
Test #11:
score: 0
Accepted
time: 73ms
memory: 2728kb
input:
5 200 8 870822545 888011437 384726727 366602674 888011437 384726727 384726727 366602674 870822545 870822545 384726727 651014332 10 888011437 411902203 611980057 910184732 411902203 651014332 411902203 723545326 5 3 319317853 476997146 910184732 8 888011437 651014332 611980057 7 611980057 910184732 5...
output:
26138916026487 24620851403857 25071187076679 25469429774328 30775803237893
result:
ok 5 number(s): "26138916026487 24620851403857 ...9 25469429774328 30775803237893"
Test #12:
score: 0
Accepted
time: 78ms
memory: 2620kb
input:
5 200 817980653 817980653 125172097 125172097 817980653 163615641 163615641 817980653 817980653 668379506 817980653 125172097 163615641 163615641 125172097 125172097 125172097 125172097 668379506 817980653 817980653 163615641 817980653 817980653 817980653 817980653 817980653 163615641 163615641 6683...
output:
26176012030413 25187907268116 26211235264533 24618377847566 26109975005241
result:
ok 5 number(s): "26176012030413 25187907268116 ...3 24618377847566 26109975005241"
Test #13:
score: 0
Accepted
time: 82ms
memory: 2636kb
input:
5 200 212397750 992618221 212397750 992618221 992618221 212397750 992618221 992618221 992618221 992618221 992618221 212397750 2 992618221 992618221 992618221 212397750 212397750 992618221 212397750 212397750 992618221 212397750 212397750 992618221 992618221 992618221 992618221 212397750 212397750 21...
output:
24420005315074 25336424651447 23383079383207 25959789505886 25582059787979
result:
ok 5 number(s): "24420005315074 25336424651447 ...7 25959789505886 25582059787979"
Test #14:
score: 0
Accepted
time: 405ms
memory: 5908kb
input:
2 500 250285849 580799867 401195916 661392649 274956707 428122906 643570314 597693323 592665916 548828299 95425938 535055216 384703504 881144262 438319718 745176673 592665916 880144539 422267581 531703035 896349921 462725647 550924100 68263737 86309277 974901795 379678136 311335012 808714258 8693175...
output:
148932394479904 154174289817183
result:
ok 2 number(s): "148932394479904 154174289817183"
Test #15:
score: 0
Accepted
time: 412ms
memory: 5976kb
input:
2 500 949563149 328612154 460785000 575821013 653281828 795841469 254532165 949563149 201859963 321853857 543557486 260875897 615307892 283709631 56492240 73771155 907703161 246563892 962285534 213433892 254428673 378181126 231227997 916759825 389322999 543557486 254428673 382216426 520489024 415367...
output:
152920875589467 146994747277368
result:
ok 2 number(s): "152920875589467 146994747277368"
Test #16:
score: 0
Accepted
time: 409ms
memory: 5968kb
input:
2 500 199 123 12 243 208 167 191 187 212 45 214 160 29 209 154 102 124 140 155 90 119 47 214 171 103 200 165 16 198 231 202 145 19 176 40 193 183 50 212 28 105 238 177 179 127 116 204 67 243 149 93 23 222 116 200 38 149 174 169 219 122 153 92 216 8 67 58 181 185 232 138 189 133 59 72 210 106 111 30 ...
output:
166697813512230 163068164683089
result:
ok 2 number(s): "166697813512230 163068164683089"
Test #17:
score: 0
Accepted
time: 428ms
memory: 6016kb
input:
2 500 47 873285980 79 849771068 74 1 44 94 120 19 200446046 77 11 22 17 34 72 538801034 972859531 26 86 773234986 43 65 189731974 213731477 665326879 74 8 99 16 501881943 256119516 4 81 5 94 392347711 213731477 13 172643627 91 82 733662021 14 125 60 20 121 154440980 463976233 690756841 208950480 122...
output:
173330999736669 152174681452318
result:
ok 2 number(s): "173330999736669 152174681452318"
Test #18:
score: 0
Accepted
time: 423ms
memory: 5896kb
input:
2 500 540767236 963353518 561314711 81529695 7 922697634 919109514 767431537 478297881 493445298 63090798 406478570 11 55 32 56 162788153 401080796 432220145 919109514 52 56 41 23 120695251 54 561314711 493445298 705279452 358783590 509626765 182281030 614041703 44261929 681696090 561314711 16278815...
output:
159663591152060 158072356086552
result:
ok 2 number(s): "159663591152060 158072356086552"
Test #19:
score: 0
Accepted
time: 455ms
memory: 6032kb
input:
2 500 266649322 682547799 808972918 596605297 217916121 107173579 413534051 217916121 934948565 27 422367079 422367079 217916121 87875810 87875810 413534051 13 169854310 202383590 314937934 283020826 632112772 986212611 169854310 87875810 596605297 19 808972918 836612378 733968754 733968754 63211277...
output:
169410553734380 165802983119455
result:
ok 2 number(s): "169410553734380 165802983119455"
Test #20:
score: 0
Accepted
time: 484ms
memory: 6004kb
input:
2 500 583670485 13 2608273 847215851 556630050 554918196 732375307 272837728 899937572 2608273 732375307 554918196 732375307 847215851 3 856869545 272837728 554918196 847215851 7 2608273 847215851 317707407 899937572 554918196 583670485 879430504 2 965838562 847215851 879430504 272837728 556630050 8...
output:
158326373826089 150187630936592
result:
ok 2 number(s): "158326373826089 150187630936592"
Test #21:
score: 0
Accepted
time: 535ms
memory: 6072kb
input:
2 500 756582711 575924897 118687709 695386745 575924897 695386745 897710981 239579019 897710981 897710981 695386745 695386745 756582711 695386745 575924897 118687709 756582711 695386745 239579019 239579019 4 756582711 575924897 239579019 575924897 1 239579019 575924897 756582711 239579019 575924897 ...
output:
176833038255727 153234216106459
result:
ok 2 number(s): "176833038255727 153234216106459"
Test #22:
score: 0
Accepted
time: 571ms
memory: 6008kb
input:
2 500 270188663 76390750 76390750 270188663 270188663 76390750 76390750 270188663 76390750 270188663 76390750 76390750 76390750 270188663 270188663 76390750 76390750 270188663 270188663 270188663 76390750 270188663 270188663 270188663 270188663 270188663 76390750 270188663 270188663 270188663 270188...
output:
160330837189026 149529694641768
result:
ok 2 number(s): "160330837189026 149529694641768"
Extra Test:
score: 0
Extra Test Passed