QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#309848 | #8132. Freshman's Dream | ucup-team296# | AC ✓ | 137ms | 2192kb | Rust | 18.7kb | 2024-01-20 21:23:55 | 2024-01-20 21:23:56 |
Judging History
answer
//
pub mod solution {
//{"name":"ucup19_e","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"ucup19_e"}}}
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::memo::memoization_5d::Memoization5d;
use crate::algo_lib::misc::recursive_function::Callable5;
type PreCalc = ();
fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &PreCalc) {
let n = input.read_u64();
let mut mem = Memoization5d::new(
61,
2,
2,
2,
2,
|mem,
bit,
carry_a_plus_b,
carry_n_plus_b,
a_non_zero,
b_non_zero|
-> Option<(usize, usize)> {
if bit == 60 {
if carry_a_plus_b != carry_n_plus_b || a_non_zero == 0 || b_non_zero == 0 {
None
} else {
Some((0, 0))
}
} else {
let bit_n = ((n >> bit) & 1) as usize;
for bit_a in 0..2 {
for bit_b in 0..2 {
let bit_a_plub_b = bit_a ^ bit_b ^ carry_a_plus_b;
let new_carry_a_plus_b = (bit_a + bit_b + carry_a_plus_b) >> 1;
let bit_n_plus_b = bit_n ^ bit_b ^ carry_n_plus_b;
let new_carry_n_plus_b = (bit_n + bit_b + carry_n_plus_b) >> 1;
if bit_a_plub_b == (bit_a ^ bit_n_plus_b) {
if let Some((a, b)) = mem.call(
bit + 1,
new_carry_a_plus_b,
new_carry_n_plus_b,
a_non_zero | bit_a,
b_non_zero | bit_b,
) {
return Some((a * 2 + bit_a, b * 2 + bit_b));
}
}
}
}
None
}
},
);
out.print_line(mem.call(0, 0, 0, 0, 0));
}
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
let pre_calc = ();
#[allow(dead_code)]
enum TestType {
Single,
MultiNumber,
MultiEof,
}
let test_type = TestType::MultiNumber;
match test_type {
TestType::Single => solve(&mut input, &mut output, 1, &pre_calc),
TestType::MultiNumber => {
let t = input.read();
for i in 1..=t {
solve(&mut input, &mut output, i, &pre_calc);
}
}
TestType::MultiEof => {
let mut i = 1;
while input.peek().is_some() {
solve(&mut input, &mut output, i, &pre_calc);
i += 1;
}
}
}
output.flush();
input.skip_whitespace();
input.peek().is_none()
}
}
pub mod algo_lib {
pub mod collections {
pub mod md_arr {
pub mod arr5d {
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;
#[derive(Clone, Eq, PartialEq)]
pub struct Arr5d<T> {
d1: usize,
d2: usize,
d3: usize,
d4: usize,
d5: usize,
data: Vec<T>,
}
impl<T: Clone> Arr5d<T> {
pub fn new(d1: usize, d2: usize, d3: usize, d4: usize, d5: usize, value: T) -> Self {
Self {
d1,
d2,
d3,
d4,
d5,
data: vec![value; d1 * d2 * d3 * d4 * d5],
}
}
}
impl<T> Arr5d<T> {
pub fn generate<F>(d1: usize, d2: usize, d3: usize, d4: usize, d5: usize, mut gen: F) -> Self
where
F: FnMut(usize, usize, usize, usize, usize) -> T,
{
let mut data = Vec::with_capacity(d1 * d2 * d3 * d4 * d5);
for i in 0..d1 {
for j in 0..d2 {
for k in 0..d3 {
for l in 0..d4 {
for m in 0..d5 {
data.push(gen(i, j, k, l, m));
}
}
}
}
}
Self {
d1,
d2,
d3,
d4,
d5,
data,
}
}
pub fn d1(&self) -> usize {
self.d1
}
pub fn d2(&self) -> usize {
self.d2
}
pub fn d3(&self) -> usize {
self.d3
}
pub fn d4(&self) -> usize {
self.d4
}
pub fn d5(&self) -> usize {
self.d5
}
pub fn iter(&self) -> impl Iterator<Item = &T> {
self.data.iter()
}
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
self.data.iter_mut()
}
}
impl<T> Index<(usize, usize, usize, usize, usize)> for Arr5d<T> {
type Output = T;
fn index(&self, (a1, a2, a3, a4, a5): (usize, usize, usize, usize, usize)) -> &Self::Output {
assert!(a1 < self.d1);
assert!(a2 < self.d2);
assert!(a3 < self.d3);
assert!(a4 < self.d4);
assert!(a5 < self.d5);
&self.data[(((a1 * self.d2 + a2) * self.d3 + a3) * self.d4 + a4) * self.d5 + a5]
}
}
impl<T> IndexMut<(usize, usize, usize, usize, usize)> for Arr5d<T> {
fn index_mut(
&mut self,
(a1, a2, a3, a4, a5): (usize, usize, usize, usize, usize),
) -> &mut Self::Output {
assert!(a1 < self.d1);
assert!(a2 < self.d2);
assert!(a3 < self.d3);
assert!(a5 < self.d5);
&mut self.data[(((a1 * self.d2 + a2) * self.d3 + a3) * self.d4 + a4) * self.d5 + a5]
}
}
impl<T: Writable> Writable for Arr5d<T> {
fn write(&self, output: &mut Output) {
let mut at = 0usize;
for i in 0..self.d1 {
if i != 0 {
output.put(b'\n');
}
for j in 0..self.d2 {
if j != 0 {
output.put(b'\n');
}
for k in 0..self.d3 {
if k != 0 {
output.put(b'\n');
}
for l in 0..self.d4 {
if l != 0 {
output.put(b'\n');
}
for m in 0..self.d5 {
if m != 0 {
output.put(b' ');
}
self.data[at].write(output);
at += 1;
}
}
}
}
}
}
}
pub trait Arr5dRead {
fn read_5d_table<T: Readable>(
&mut self,
d1: usize,
d2: usize,
d3: usize,
d4: usize,
d5: usize,
) -> Arr5d<T>;
}
impl Arr5dRead for Input<'_> {
fn read_5d_table<T: Readable>(
&mut self,
d1: usize,
d2: usize,
d3: usize,
d4: usize,
d5: usize,
) -> Arr5d<T> {
Arr5d::generate(d1, d2, d3, d4, d5, |_, _, _, _, _| self.read())
}
}
impl<T: Readable> Readable for Arr5d<T> {
fn read(input: &mut Input) -> Self {
let d1 = input.read();
let d2 = input.read();
let d3 = input.read();
let d4 = input.read();
let d5 = input.read();
input.read_5d_table(d1, d2, d3, d4, d5)
}
}
impl<T: Clone> Arr5d<T> {
pub fn fill(&mut self, elem: T) {
self.data.legacy_fill(elem);
}
}
}
}
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 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 !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()
}
//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::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]) {
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);
}
}
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_ref(self.iter());
}
}
impl<T: Writable, const N: usize> Writable for [T; N] {
fn write(&self, output: &mut Output) {
output.print_iter_ref(self.iter());
}
}
impl<T: Writable> 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}
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)
}
}
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 memo {
pub mod memoization_5d {
use crate::algo_lib::collections::md_arr::arr5d::Arr5d;
use crate::algo_lib::misc::recursive_function::Callable5;
pub struct Memoization5d<F, Output>
where
F: FnMut(
&mut dyn Callable5<usize, usize, usize, usize, usize, Output>,
usize,
usize,
usize,
usize,
usize,
) -> Output,
{
f: std::cell::UnsafeCell<F>,
res: Arr5d<Option<Output>>,
}
impl<F, Output: Clone> Memoization5d<F, Output>
where
F: FnMut(
&mut dyn Callable5<usize, usize, usize, usize, usize, Output>,
usize,
usize,
usize,
usize,
usize,
) -> Output,
{
pub fn new(d1: usize, d2: usize, d3: usize, d4: usize, d5: usize, f: F) -> Self {
Self {
f: std::cell::UnsafeCell::new(f),
res: Arr5d::new(d1, d2, d3, d4, d5, None),
}
}
}
impl<F, Output: Clone> Callable5<usize, usize, usize, usize, usize, Output>
for Memoization5d<F, Output>
where
F: FnMut(
&mut dyn Callable5<usize, usize, usize, usize, usize, Output>,
usize,
usize,
usize,
usize,
usize,
) -> Output,
{
fn call(&mut self, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) -> Output {
match self.res[(a1, a2, a3, a4, a5)].as_ref() {
None => {
let res = unsafe { (*self.f.get())(self, a1, a2, a3, a4, a5) };
self.res[(a1, a2, a3, a4, a5)] = Some(res.clone());
res
}
Some(res) => res.clone(),
}
}
}
}
}
pub mod recursive_function {
use std::marker::PhantomData;
macro_rules! recursive_function {
($name: ident, $trait: ident, ($($type: ident $arg: ident,)*)) => {
pub trait $trait<$($type, )*Output> {
fn call(&mut self, $($arg: $type,)*) -> Output;
}
pub struct $name<F, $($type, )*Output>
where
F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
{
f: std::cell::UnsafeCell<F>,
$($arg: PhantomData<$type>,
)*
phantom_output: PhantomData<Output>,
}
impl<F, $($type, )*Output> $name<F, $($type, )*Output>
where
F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
{
pub fn new(f: F) -> Self {
Self {
f: std::cell::UnsafeCell::new(f),
$($arg: Default::default(),
)*
phantom_output: Default::default(),
}
}
}
impl<F, $($type, )*Output> $trait<$($type, )*Output> for $name<F, $($type, )*Output>
where
F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
{
fn call(&mut self, $($arg: $type,)*) -> Output {
unsafe { (*self.f.get())(self, $($arg, )*) }
}
}
}
}
recursive_function!(RecursiveFunction0, Callable0, ());
recursive_function!(RecursiveFunction, Callable, (Arg arg,));
recursive_function!(RecursiveFunction2, Callable2, (Arg1 arg1, Arg2 arg2,));
recursive_function!(RecursiveFunction3, Callable3, (Arg1 arg1, Arg2 arg2, Arg3 arg3,));
recursive_function!(RecursiveFunction4, Callable4, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,));
recursive_function!(RecursiveFunction5, Callable5, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5,));
recursive_function!(RecursiveFunction6, Callable6, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6,));
recursive_function!(RecursiveFunction7, Callable7, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7,));
recursive_function!(RecursiveFunction8, Callable8, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8,));
recursive_function!(RecursiveFunction9, Callable9, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8, Arg9 arg9,));
}
}
}
fn main() {
let mut sin = std::io::stdin();
let input = if false {
algo_lib::io::input::Input::new_with_size(&mut sin, 1)
} else {
algo_lib::io::input::Input::new(&mut sin)
};
let mut stdout = std::io::stdout();
let output = if false {
algo_lib::io::output::Output::new_with_auto_flush(&mut stdout)
} else {
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: 2100kb
input:
5 2 3 6 10 18
output:
1 1 -1 3 1 5 5 9 9
result:
ok ok
Test #2:
score: 0
Accepted
time: 90ms
memory: 2192kb
input:
100000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
1 1 -1 2 2 -1 3 1 -1 4 4 -1 5 5 -1 6 2 -1 7 1 -1 8 8 -1 9 9 -1 10 10 -1 11 9 -1 12 4 -1 13 5 -1 14 2 -1 15 1 -1 16 16 -1 17 17 -1 18 18 -1 19 17 -1 20 20 -1 21 21 -1 22 18 -1 23 17 -1 24 8 -1 25 9 -1 26 10 -1 27 9 -1 28 4 -1 29 5 -1 30 2 -1 31 1 -1 32 32 -1 33 33 -1 34 34 -1 35 33 -1 36 36 -1 37 37 ...
result:
ok ok
Test #3:
score: 0
Accepted
time: 98ms
memory: 2048kb
input:
100000 76316 55087 1035148 480523 322879 607749 440658 434700 941531 657517 247448 953385 569641 592597 188131 769378 397552 94739 487375 142576 407344 532339 798526 521099 294428 414998 415977 646853 941103 21816 299379 1029240 171218 784108 711027 121363 223925 197035 899124 613355 178257 213375 3...
output:
38158 38146 -1 517574 9282 -1 -1 -1 220329 83113 217350 86274 -1 -1 123724 8516 -1 -1 -1 -1 384689 279185 198776 67592 -1 -1 71288 70152 203672 67720 -1 399263 135297 -1 147214 131330 207499 76425 -1 -1 -1 10908 10884 -1 514620 18948 85609 82473 392054 264466 -1 -1 -1 -1 449562 148490 -1 -1 -1 16321...
result:
ok ok
Test #4:
score: 0
Accepted
time: 120ms
memory: 2076kb
input:
100000 279938093875 699023415517 1048269983590 537007992988 908117019805 683806387338 334400705624 484515916103 888494261285 220468538805 253319179778 357268673752 644637898889 919322454545 854350801341 1022830170092 486578580191 750669735889 4206967959 937169662800 852140555915 924210466276 2534095...
output:
-1 -1 524134991795 43086069905 268503996494 10805856322 -1 341903193669 277176685125 167200352812 146635631140 -1 -1 -1 126659589889 21558726913 178634336876 174233528868 -1 -1 -1 511415085046 73326010386 -1 -1 -1 468584831400 159053580456 -1 462105233138 174223147538 126704791299 19328442625 416552...
result:
ok ok
Test #5:
score: 0
Accepted
time: 137ms
memory: 2188kb
input:
100000 1040995214518856201 963834979320064344 718413469456747239 720594233881658007 133510227004253867 342816554559204856 24244360004792499 32003367585596768 68757795892900724 211638297745299764 478782413658379896 503496146580989968 288072253164348517 131667719615682949 186429177128265488 6043925869...
output:
-1 481917489660032172 184653225122075812 -1 -1 -1 171408277279602428 153142352523825668 -1 16001683792798384 2332142851924624 34378897946450362 2851188810844298 105819148872649882 76578874066273418 239391206829189948 95144075205814532 251748073290494984 72656312768533512 -1 -1 93214588564132744 9265...
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 2100kb
input:
1 1152921504606846975
output:
-1
result:
ok ok
Extra Test:
score: 0
Extra Test Passed