QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#348863#8332. Two in Oneucup-team296#AC ✓25ms3860kbRust18.5kb2024-03-09 21:58:332024-03-09 21:58:34

Judging History

你现在查看的是最新测评结果

  • [2024-03-09 21:58:34]
  • 评测
  • 测评结果:AC
  • 用时:25ms
  • 内存:3860kb
  • [2024-03-09 21:58:33]
  • 提交

answer

// 
pub mod solution {
//{"name":"uc25_e","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""},{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"uc25_e"}}}

use crate::algo_lib::collections::slice_ext::qty::Qty;
use crate::algo_lib::collections::vec_ext::inc_dec::IncDec;
use crate::algo_lib::collections::vec_ext::sorted::Sorted;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::numbers::num_traits::bit_ops::BitOps;

type PreCalc = ();

fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &mut PreCalc) {
let n = input.read_size();
let c = input.read_size_vec(n).dec();

if n == 1 {
out.print_line(1);
return;
}
let q = c.qty_bound(n).sorted();
let x = q[n - 1];
let y = q[n - 2];
for i in (0..30).rev() {
if x.is_set(i) && y.is_set(i) {
out.print_line(x | y | usize::all_bits(i));
return;
}
}
out.print_line(x | y);
}

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
let mut 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, &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();
if false {
true
} else {
input.skip_whitespace();
input.peek().is_none()
}
}

}
pub mod algo_lib {
pub mod collections {
pub mod slice_ext {
pub mod qty {
pub trait Qty {
fn qty_bound(&self, bound: usize) -> Vec<usize>;
fn qty(&self) -> Vec<usize>;
}

impl Qty for [usize] {
fn qty_bound(&self, bound: usize) -> Vec<usize> {
let mut res = vec![0; bound];
for i in self.iter() {
res[*i] += 1;
}
res
}

fn qty(&self) -> Vec<usize> {
if self.is_empty() {
Vec::new()
} else {
self.qty_bound(self.iter().max().unwrap() + 1)
}
}
}
}
}
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 inc_dec {
use crate::algo_lib::numbers::num_traits::algebra::AdditionMonoidWithSub;
use crate::algo_lib::numbers::num_traits::algebra::One;

pub trait IncDec {
#[must_use]
fn inc(self) -> Self;
#[must_use]
fn dec(self) -> Self;
}

impl<T: AdditionMonoidWithSub + One> IncDec for Vec<T> {
fn inc(mut self) -> Self {
self.iter_mut().for_each(|i| *i += T::one());
self
}

fn dec(mut self) -> Self {
self.iter_mut().for_each(|i| *i -= T::one());
self
}
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec for Vec<(T, U)> {
fn inc(mut self) -> Self {
self.iter_mut().for_each(|(i, j)| {
*i += T::one();
*j += U::one();
});
self
}

fn dec(mut self) -> Self {
self.iter_mut().for_each(|(i, j)| {
*i -= T::one();
*j -= U::one();
});
self
}
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V> IncDec for Vec<(T, U, V)> {
fn inc(mut self) -> Self {
self.iter_mut().for_each(|(i, j, _)| {
*i += T::one();
*j += U::one();
});
self
}

fn dec(mut self) -> Self {
self.iter_mut().for_each(|(i, j, _)| {
*i -= T::one();
*j -= U::one();
});
self
}
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W> IncDec
for Vec<(T, U, V, W)>
{
fn inc(mut self) -> Self {
self.iter_mut().for_each(|(i, j, ..)| {
*i += T::one();
*j += U::one();
});
self
}

fn dec(mut self) -> Self {
self.iter_mut().for_each(|(i, j, ..)| {
*i -= T::one();
*j -= U::one();
});
self
}
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W, X> IncDec
for Vec<(T, U, V, W, X)>
{
fn inc(mut self) -> Self {
self.iter_mut().for_each(|(i, j, ..)| {
*i += T::one();
*j += U::one();
});
self
}

fn dec(mut self) -> Self {
self.iter_mut().for_each(|(i, j, ..)| {
*i -= T::one();
*j -= U::one();
});
self
}
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec for (T, U) {
fn inc(mut self) -> Self {
self.0 += T::one();
self.1 += U::one();
self
}

fn dec(mut self) -> Self {
self.0 -= T::one();
self.1 -= U::one();
self
}
}
}
pub mod sorted {
pub trait Sorted {
fn sorted(self) -> Self;
}

impl<T: Ord> Sorted for Vec<T> {
fn sorted(mut self) -> Self {
self.sort();
self
}
}
}
}
}
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 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> 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)
}
}

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 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 bit_ops {
use crate::algo_lib::numbers::num_traits::algebra::One;
use crate::algo_lib::numbers::num_traits::algebra::Zero;
use std::ops::BitAnd;
use std::ops::BitAndAssign;
use std::ops::BitOr;
use std::ops::BitOrAssign;
use std::ops::BitXor;
use std::ops::BitXorAssign;
use std::ops::Not;
use std::ops::RangeInclusive;
use std::ops::Shl;
use std::ops::ShlAssign;
use std::ops::Shr;
use std::ops::ShrAssign;

pub trait BitOps:
Copy
+ BitAnd<Output = Self>
+ BitAndAssign
+ BitOr<Output = Self>
+ BitOrAssign
+ BitXor<Output = Self>
+ BitXorAssign
+ Not<Output = Self>
+ Shl<usize, Output = Self>
+ ShlAssign<usize>
+ Shr<usize, Output = Self>
+ ShrAssign<usize>
+ Zero
+ One
+ PartialEq
{
fn bit(at: usize) -> Self {
Self::one() << at
}

fn is_set(&self, at: usize) -> bool {
(*self >> at & Self::one()) == Self::one()
}

fn set_bit(&mut self, at: usize) {
*self |= Self::bit(at)
}

fn unset_bit(&mut self, at: usize) {
*self &= !Self::bit(at)
}

#[must_use]
fn with_bit(mut self, at: usize) -> Self {
self.set_bit(at);
self
}

#[must_use]
fn without_bit(mut self, at: usize) -> Self {
self.unset_bit(at);
self
}

fn flip_bit(&mut self, at: usize) {
*self ^= Self::bit(at)
}

fn all_bits(n: usize) -> Self {
let mut res = Self::zero();
for i in 0..n {
res.set_bit(i);
}
res
}

fn iter_all(n: usize) -> RangeInclusive<Self> {
Self::zero()..=Self::all_bits(n)
}
}

impl<
T: Copy
+ BitAnd<Output = Self>
+ BitAndAssign
+ BitOr<Output = Self>
+ BitOrAssign
+ BitXor<Output = Self>
+ BitXorAssign
+ Not<Output = Self>
+ Shl<usize, Output = Self>
+ ShlAssign<usize>
+ Shr<usize, Output = Self>
+ ShrAssign<usize>
+ One
+ Zero
+ PartialEq,
> BitOps for T
{
}

pub trait Bits: BitOps {
fn bits() -> u32;
}

macro_rules! bits_integer_impl {
($($t: ident $bits: expr),+) => {$(
impl Bits for $t {
fn bits() -> u32 {
$bits
}
}
)+};
}

bits_integer_impl!(i128 128, i64 64, i32 32, i16 16, i8 8, isize 64, u128 128, u64 64, u32 32, u16 16, u8 8, usize 64);
}
pub mod invertible {
pub trait Invertible {
type Output;

fn inv(&self) -> Option<Self::Output>;
}
}
}
}
}
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,我给组数据试试?

詳細信息

Test #1:

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

input:

1
7
1 2 3 4 3 2 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

1
9
1 1 1 1 1 2 2 2 2

output:

7

result:

ok 1 number(s): "7"

Test #3:

score: 0
Accepted
time: 7ms
memory: 2192kb

input:

50
10000
72 65 90 94 67 93 41 43 54 83 31 34 38 37 44 42 92 63 66 79 90 45 41 40 19 54 34 90 13 74 40 77 41 57 74 86 91 79 34 39 21 88 90 57 23 31 8 15 80 27 45 38 53 96 51 82 70 71 19 75 62 95 31 67 99 97 94 29 90 7 95 82 61 98 62 77 43 65 66 30 41 69 38 79 51 9 63 77 13 30 72 70 67 93 92 45 74 50 ...

output:

255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255

result:

ok 50 numbers

Test #4:

score: 0
Accepted
time: 11ms
memory: 2272kb

input:

79114
7
1 2 4 3 2 3 7
7
1 2 4 7 4 1 5
6
4 2 2 4 2 1
7
1 2 1 4 7 3 2
7
1 2 4 7 1 1 3
7
1 2 6 1 5 2 5
6
5 2 6 1 2 5
7
1 1 7 6 6 5 2
7
1 2 5 6 6 7 7
7
1 1 2 7 2 3 6
7
1 1 1 4 6 2 2
7
1 1 5 7 3 5 2
7
1 1 7 6 2 2 5
6
4 3 4 6 3 1
6
4 4 3 2 3 1
7
1 1 2 3 7 6 2
6
1 2 5 6 3 4
7
1 1 1 1 4 7 6
6
2 6 6 2 5 3
6
...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
5
3
3
3
3
3
3
3
3
3
3
3
5
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
6
3
3
3
3
5
3
3
3
5
3
3
3
3
3
3
3
3
3
3
5
3
3
3
3
3
3
3
3
3
3
3
5
3
3
3
1
3
3
3
3
3
3
5
3
3
3
3
3
3
3
3
3
3
...

result:

ok 79114 numbers

Test #5:

score: 0
Accepted
time: 11ms
memory: 1968kb

input:

50000
10
6 3 8 5 4 6 3 5 3 9
10
10 4 3 10 4 5 2 7 8 10
10
10 6 2 2 4 9 7 3 3 4
10
1 2 9 7 5 2 1 2 10 1
10
2 8 2 3 7 8 3 5 10 5
10
5 6 10 2 7 3 5 10 5 4
10
3 4 4 2 2 1 1 8 5 10
10
3 3 3 8 5 7 3 6 7 9
10
10 6 5 3 2 8 10 9 9 4
10
5 8 6 2 10 5 8 8 10 7
10
5 8 2 10 2 2 9 5 4 2
10
7 6 4 7 5 9 2 2 1 7
10
7...

output:

3
3
3
3
3
3
3
6
3
3
6
3
3
3
6
3
3
3
3
6
3
3
3
3
3
3
3
3
6
3
6
3
3
3
6
3
6
3
7
3
3
6
3
3
3
6
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
6
3
3
3
3
3
3
3
3
3
5
3
3
7
3
3
3
3
3
3
6
3
3
3
6
3
3
3
7
3
6
3
3
3
3
3
3
3
6
3
3
5
3
3
6
7
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
7
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
6
3
7
3
3
3
3
3
3
6
3
...

result:

ok 50000 numbers

Test #6:

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

input:

50000
10
2 1 2 2 2 2 1 2 1 3
10
3 2 1 3 2 2 1 2 2 3
10
3 2 1 1 2 3 2 1 1 2
10
1 1 3 2 2 1 1 1 3 1
10
1 2 1 1 2 2 1 2 3 2
10
2 2 3 1 2 1 2 3 2 2
10
1 2 2 1 1 1 1 2 2 3
10
1 1 1 2 2 2 1 2 2 3
10
3 2 2 1 1 2 3 3 3 2
10
2 2 2 1 3 2 2 2 3 2
10
2 2 1 3 1 1 3 2 2 1
10
2 2 2 2 2 3 1 1 1 2
10
2 3 2 1 1 2 2 1...

output:

7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
9
7
7
7
7
7
7
7
7
7
7
9
7
7
7
7
7
9
7
7
7
7
7
7
9
9
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
9
7
7
7
7
7
9
7
10
7
7
7
7
7
7
10
7
7
7
7
7
7
7
7
7
7
7
7
7
10
7
7
7
7
7
7
7
7
7
7
7
7...

result:

ok 50000 numbers

Test #7:

score: 0
Accepted
time: 17ms
memory: 2052kb

input:

5000
100
35 13 56 51 37 39 100 35 21 36 54 19 99 74 38 99 90 69 29 23 38 27 40 94 92 93 93 45 94 22 65 65 43 62 47 53 11 77 87 15 77 72 3 38 25 19 4 82 48 69 15 13 8 76 48 8 19 86 25 26 34 70 38 42 87 81 31 92 30 24 80 69 8 74 48 30 57 47 65 42 35 47 42 85 18 94 97 13 8 24 100 31 51 72 69 95 74 90 9...

output:

7
7
3
7
7
7
7
7
7
7
7
7
7
3
7
7
7
7
7
7
7
7
3
7
7
3
7
7
7
7
3
7
7
7
7
7
7
3
7
7
3
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
3
7
7
7
3
7
7
7
7
7
3
7
7
7
3
7
7
7
3
7
7
7
7
3
7
7
3
7
7
7
7
7
7
7
7
7
7
3
7
7
7
7
7
7
7
7
7
7
3
7
7
3
3
7
7
7
7
7
7
7
7
7
7
7
7
3
3
7
7
7
7
3
7
7
7
7
7
7
7
7
7
7
7
3
7
...

result:

ok 5000 numbers

Test #8:

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

input:

5000
100
5 3 7 7 6 6 10 5 4 6 7 4 9 8 6 9 9 8 5 4 6 5 6 9 9 9 9 6 9 4 8 8 6 7 6 7 3 8 9 3 8 8 1 6 5 4 2 9 6 8 3 3 2 8 6 2 4 9 5 5 5 8 6 6 9 9 5 9 5 4 8 8 2 8 6 5 7 6 8 6 5 6 6 9 4 9 9 3 2 4 10 5 7 8 8 9 8 9 9 8
100
6 6 4 2 6 5 9 9 6 7 9 7 6 6 3 3 4 9 7 7 9 6 9 3 6 3 10 6 8 9 8 9 5 6 3 3 5 9 8 8 8 1 ...

output:

31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
31
...

result:

ok 5000 numbers

Test #9:

score: 0
Accepted
time: 17ms
memory: 2128kb

input:

500
1000
826 799 36 103 143 218 173 682 364 907 788 338 489 308 749 437 185 166 973 723 463 220 892 883 126 274 442 324 227 772 349 202 740 43 361 521 690 113 160 281 364 507 913 552 766 661 82 931 590 896 439 701 330 538 939 710 841 660 620 727 309 506 113 55 230 459 734 675 977 737 922 642 860 894...

output:

7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
...

result:

ok 500 numbers

Test #10:

score: 0
Accepted
time: 8ms
memory: 2124kb

input:

500
1000
28 28 6 10 11 14 13 26 19 30 28 18 22 17 27 20 13 12 31 26 21 14 29 29 11 16 21 18 15 27 18 14 27 6 19 22 26 10 12 16 19 22 30 23 27 25 9 30 24 29 20 26 18 23 30 26 29 25 24 26 17 22 10 7 15 21 27 25 31 27 30 25 29 29 25 24 9 10 16 24 29 23 19 16 28 21 28 12 31 10 20 18 11 21 14 11 14 12 19...

output:

63
63
127
127
63
127
125
63
127
127
127
126
127
63
63
63
127
127
127
127
63
127
126
127
127
127
127
127
127
63
127
127
127
63
127
127
123
127
63
127
63
119
127
63
125
127
127
63
127
127
123
126
127
127
63
127
125
127
127
119
127
127
119
127
127
63
63
127
63
63
127
127
127
63
122
63
127
127
127
63
63...

result:

ok 500 numbers

Test #11:

score: 0
Accepted
time: 23ms
memory: 2284kb

input:

50
10000
5231 4283 8159 8842 4592 8761 1749 1922 2947 6985 988 1176 1520 1420 2002 1812 8626 4019 4403 6360 8219 2027 1745 1619 395 2982 1182 8185 179 5604 1659 5959 1682 3355 5489 7484 8447 6328 1184 1555 477 7889 8272 3343 544 975 80 226 6518 729 2044 1450 2904 9281 2622 6742 4921 5143 372 5695 39...

output:

7
7
7
7
7
7
7
7
7
7
7
7
15
7
15
7
7
7
7
7
7
7
7
7
7
7
15
7
15
7
7
7
7
7
7
15
7
7
7
7
15
7
15
7
7
7
7
7
7
15

result:

ok 50 numbers

Test #12:

score: 0
Accepted
time: 25ms
memory: 3860kb

input:

5
100000
91675 46565 38979 3941 53894 98418 84900 84804 53487 7391 37558 42152 21892 48134 40091 35126 70005 1153 61201 47390 57436 20581 76773 48574 35571 42660 42943 41736 20593 53925 22043 8372 31184 39982 17663 22303 48407 27491 22257 13831 393 13278 29991 80618 89887 63441 66588 3667 95209 5383...

output:

7
15
7
15
15

result:

ok 5 number(s): "7 15 7 15 15"

Test #13:

score: 0
Accepted
time: 8ms
memory: 3696kb

input:

5
100000
302 215 197 62 232 313 291 291 231 85 193 205 147 219 200 187 264 33 247 217 239 143 277 220 188 206 207 204 143 232 148 91 176 199 132 149 220 165 149 117 19 115 173 283 299 251 258 60 308 232 146 306 197 294 154 246 245 305 134 237 129 217 233 192 65 210 290 153 309 212 229 155 157 33 260...

output:

1023
1023
1023
1023
1023

result:

ok 5 number(s): "1023 1023 1023 1023 1023"

Test #14:

score: 0
Accepted
time: 10ms
memory: 3756kb

input:

5
99999
5 5 5 5 5 5 4 5 4 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 4 5 5 5 5 4 5 5 3 5 5 5 5 5 5 5 5 3 5 5 4 5 5 5 3 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 4 5 5 5 5 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 ...

output:

98303
98303
98303
98303
98303

result:

ok 5 number(s): "98303 98303 98303 98303 98303"

Test #15:

score: 0
Accepted
time: 19ms
memory: 3764kb

input:

5
99999
63915 63915 63915 63915 38059 63915 63915 63915 25192 63915 1024 63915 63915 63915 63915 63915 63915 63915 63915 63896 63915 63915 14963 63915 63915 63915 52208 84889 63915 63915 63915 63915 63915 40674 63915 62258 63915 63915 63915 16744 63915 63915 63915 96429 91077 63915 63915 63915 43576...

output:

65535
83967
65535
98303
57343

result:

ok 5 number(s): "65535 83967 65535 98303 57343"

Test #16:

score: 0
Accepted
time: 15ms
memory: 2032kb

input:

500
999
324 675 675 324 675 675 675 675 675 324 675 324 675 324 324 675 324 675 675 675 324 675 324 675 324 675 324 675 324 675 675 324 675 675 675 675 675 324 675 324 675 675 675 675 324 324 675 675 324 324 675 675 324 675 675 675 324 675 324 675 675 675 675 675 675 675 675 675 675 675 675 324 675 ...

output:

999
551
287
639
767
735
511
511
511
783
511
639
703
991
895
879
511
511
511
415
471
503
959
511
511
831
383
511
767
511
103
895
990
767
759
255
767
639
469
959
511
447
703
511
511
895
959
511
959
703
255
879
815
767
975
991
895
983
983
767
987
255
767
511
703
511
860
927
735
511
831
991
767
855
127
...

result:

ok 500 numbers

Test #17:

score: 0
Accepted
time: 18ms
memory: 2300kb

input:

50
10000
3548 5617 5617 3548 3548 1832 5617 5617 5617 3548 5617 5617 3548 5617 4445 3548 3548 3548 3548 5617 3548 5617 5617 5617 3548 3548 3548 5617 3548 5617 5617 3548 3548 5617 4470 3548 3548 5617 5617 5617 5617 5617 3548 5617 5617 3339 5617 3548 3548 6761 3548 3548 5617 3548 5617 5617 3548 3548 3...

output:

8191
4095
9343
9711
6143
6143
8191
6143
9939
5631
7487
8191
9215
9215
9215
8191
8191
8191
1535
8191
7679
7167
6142
8188
2047
9855
9215
6143
7999
9654
4095
7791
9263
6143
9215
5375
8382
9215
4095
7623
8191
8191
6143
3327
8063
7167
7167
4095
8191
8191

result:

ok 50 numbers

Test #18:

score: 0
Accepted
time: 16ms
memory: 2132kb

input:

500
999
675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 ...

output:

999
551
287
639
767
735
511
511
511
783
511
639
703
991
895
879
511
511
511
415
471
503
959
511
511
831
383
511
767
511
103
895
990
767
759
255
767
639
469
959
511
447
703
511
511
895
959
511
959
703
255
879
815
767
975
991
895
983
983
767
987
255
767
511
703
511
860
927
735
511
831
991
767
855
127
...

result:

ok 500 numbers

Extra Test:

score: 0
Extra Test Passed