QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#804418 | #9865. Dolls | ucup-team296# | TL | 564ms | 2276kb | Rust | 20.0kb | 2024-12-07 22:28:49 | 2024-12-07 22:28:49 |
Judging History
answer
// https://contest.ucup.ac/contest/1871/problem/9865
pub mod solution {
//{"name":"D. Dolls","group":"Universal Cup - The 3rd Universal Cup. Stage 20: Kunming","url":"https://contest.ucup.ac/contest/1871/problem/9865","interactive":false,"timeLimit":1000,"tests":[{"input":"8\n4\n2 1 4 3\n4\n1 4 2 3\n4\n3 1 4 2\n5\n1 3 5 2 4\n5\n1 4 2 5 3\n5\n2 5 3 1 4\n6\n1 3 6 5 2 4\n6\n2 5 1 3 6 4\n","output":"3\n3\n2\n3\n3\n3\n4\n4\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"DDolls"}}}
#[allow(unused)]
use crate::dbg;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::binary_search::binary_search_first_true;
fn can_split(a: &[usize], from: usize) -> bool {
let n = a.len();
if n <= 2 {
return true;
}
let to = from + a.len();
let mut prefix_min = usize::MAX;
let mut suffix_min = usize::MAX;
let mut prefix_max = 0;
let mut suffix_max = 0;
for len in 1..a.len() {
prefix_min = prefix_min.min(a[len - 1] - from);
prefix_max = prefix_max.max(a[len - 1] - from);
suffix_min = suffix_min.min(a[n - len] - from);
suffix_max = suffix_max.max(a[n - len] - from);
if prefix_max == len - 1 {
return can_split(&a[..len], from) && can_split(&a[len..], from + len);
}
if prefix_min + len == to {
return can_split(&a[..len], to - len) && can_split(&a[len..], from);
}
if suffix_max == len - 1 {
return can_split(&a[..n - len], from + len) && can_split(&a[n - len..], from);
}
if suffix_min + len == to {
return can_split(&a[..n - len], from) && can_split(&a[n - len..], to - len);
}
}
false
}
fn is_good(a: &[usize]) -> bool {
let mut all_vals = a.to_vec();
all_vals.sort();
let mut a = a.to_vec();
for i in 0..a.len() {
a[i] = all_vals.binary_search(&a[i]).unwrap();
}
can_split(&a, 0)
}
fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
let tc = input.usize();
for _ in 0..tc {
let n = input.usize();
let a = input.vec::<usize>(n);
let mut n_comps = 0;
let mut a = a.as_slice();
while !a.is_empty() {
let mut ok_len = 1;
while ok_len < a.len() {
let test_len = (ok_len * 2).min(a.len());
if is_good(&a[..test_len]) {
ok_len = test_len;
} else {
break;
}
}
if ok_len != a.len() {
let bad_len = a.len();
ok_len = binary_search_first_true(ok_len..bad_len, |check_len| {
!is_good(&a[..check_len])
}) - 1;
}
n_comps += 1;
a = &a[ok_len..];
}
out.println(n - n_comps);
}
}
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
solve(&mut input, &mut output, 1);
output.flush();
true
}
}
pub mod algo_lib {
#![feature(test)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;
pub struct Input {
input: Box<dyn Read>,
buf: Vec<u8>,
at: usize,
buf_read: usize,
}
macro_rules! read_integer_fun {
($t:ident) => {
#[allow(unused)]
pub fn $t(&mut self) -> $t {
self.read_integer()
}
};
}
impl Input {
const DEFAULT_BUF_SIZE: usize = 4096;
///
/// Using with stdin:
/// ```no_run
/// use algo_lib::io::input::Input;
/// let stdin = std::io::stdin();
/// let input = Input::new(Box::new(stdin));
/// ```
///
/// For read files use ``new_file`` instead.
///
///
pub fn new(input: Box<dyn Read>) -> Self {
Self {
input,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
buf_read: 0,
}
}
pub fn new_stdin() -> Self {
let stdin = std::io::stdin();
Self::new(Box::new(stdin))
}
pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
let file = std::fs::File::open(&path)
.unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
Self::new(Box::new(file))
}
pub fn new_with_size(input: Box<dyn Read>, buf_size: usize) -> Self {
Self {
input,
buf: vec![0; buf_size],
at: 0,
buf_read: 0,
}
}
pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
let file = std::fs::File::open(&path)
.unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
Self::new_with_size(Box::new(file), buf_size)
}
pub fn get(&mut self) -> Option<u8> {
if self.refill_buffer() {
let res = self.buf[self.at];
self.at += 1;
Some(res)
} else {
None
}
}
pub fn peek(&mut self) -> Option<u8> {
if self.refill_buffer() {
Some(self.buf[self.at])
} else {
None
}
}
pub fn skip_whitespace(&mut self) {
while let Some(b) = self.peek() {
if !char::from(b).is_whitespace() {
return;
}
self.get();
}
}
pub fn next_token(&mut self) -> Option<Vec<u8>> {
self.skip_whitespace();
let mut res = Vec::new();
while let Some(c) = self.get() {
if char::from(c).is_whitespace() {
break;
}
res.push(c);
}
if res.is_empty() {
None
} else {
Some(res)
}
}
//noinspection RsSelfConvention
pub fn is_exhausted(&mut self) -> bool {
self.peek().is_none()
}
pub fn has_more_elements(&mut self) -> bool {
!self.is_exhausted()
}
pub fn read<T: Readable>(&mut self) -> T {
T::read(self)
}
pub fn vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
let mut res = Vec::with_capacity(size);
for _ in 0usize..size {
res.push(self.read());
}
res
}
pub fn string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
let mut res = Vec::with_capacity(size);
for _ in 0usize..size {
res.push(self.string());
}
res
}
pub fn read_line(&mut self) -> String {
let mut res = String::new();
while let Some(c) = self.get() {
if c == b'\n' {
break;
}
if c == b'\r' {
if self.peek() == Some(b'\n') {
self.get();
}
break;
}
res.push(c.into());
}
res
}
#[allow(clippy::should_implement_trait)]
pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
InputIterator {
input: self,
phantom: Default::default(),
}
}
fn read_integer<T: FromStr + Debug>(&mut self) -> T
where
<T as FromStr>::Err: Debug,
{
let res = self.read_string();
res.parse::<T>().unwrap()
}
fn read_string(&mut self) -> String {
match self.next_token() {
None => {
panic!("Input exhausted");
}
Some(res) => unsafe { String::from_utf8_unchecked(res) },
}
}
pub fn string_as_string(&mut self) -> String {
self.read_string()
}
pub fn string(&mut self) -> Vec<u8> {
self.read_string().into_bytes()
}
fn read_char(&mut self) -> char {
self.skip_whitespace();
self.get().unwrap().into()
}
fn read_float(&mut self) -> f64 {
self.read_string().parse().unwrap()
}
pub fn f64(&mut self) -> f64 {
self.read_float()
}
fn refill_buffer(&mut self) -> bool {
if self.at == self.buf_read {
self.at = 0;
self.buf_read = self.input.read(&mut self.buf).unwrap();
self.buf_read != 0
} else {
true
}
}
read_integer_fun!(i32);
read_integer_fun!(i64);
read_integer_fun!(i128);
read_integer_fun!(u32);
read_integer_fun!(u64);
read_integer_fun!(usize);
}
pub trait Readable {
fn read(input: &mut Input) -> Self;
}
impl Readable for String {
fn read(input: &mut Input) -> Self {
input.read_string()
}
}
impl Readable for char {
fn read(input: &mut Input) -> Self {
input.read_char()
}
}
impl Readable for f64 {
fn read(input: &mut Input) -> Self {
input.read_string().parse().unwrap()
}
}
impl Readable for f32 {
fn read(input: &mut Input) -> Self {
input.read_string().parse().unwrap()
}
}
impl<T: Readable> Readable for Vec<T> {
fn read(input: &mut Input) -> Self {
let size = input.read();
input.vec(size)
}
}
pub struct InputIterator<T: Readable> {
input: Input,
phantom: PhantomData<T>,
}
impl<T: Readable> Iterator for InputIterator<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.input.skip_whitespace();
self.input.peek().map(|_| self.input.read())
}
}
macro_rules! read_integer {
($t:ident) => {
impl Readable for $t {
fn read(input: &mut Input) -> Self {
input.read_integer()
}
}
};
}
read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;
pub struct Output {
output: Box<dyn Write>,
buf: Vec<u8>,
at: usize,
auto_flush: bool,
}
impl Output {
const DEFAULT_BUF_SIZE: usize = 4096;
pub fn new(output: Box<dyn Write>) -> Self {
Self {
output,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
auto_flush: false,
}
}
pub fn new_stdout() -> Self {
let stdout = std::io::stdout();
Self::new(Box::new(stdout))
}
pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
let file = std::fs::File::create(path).unwrap();
Self::new(Box::new(file))
}
pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
Self {
output,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
auto_flush: true,
}
}
pub fn flush(&mut self) {
if self.at != 0 {
self.output.write_all(&self.buf[..self.at]).unwrap();
self.at = 0;
self.output.flush().expect("Couldn't flush output");
}
}
pub fn print<T: Writable>(&mut self, s: T) {
s.write(self);
}
pub fn println<T: Writable>(&mut self, s: T) {
s.write(self);
self.put(b'\n');
}
pub fn put(&mut self, b: u8) {
self.buf[self.at] = b;
self.at += 1;
if self.at == self.buf.len() {
self.flush();
}
}
pub fn maybe_flush(&mut self) {
if self.auto_flush {
self.flush();
}
}
pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
for i in arg {
i.write(self);
self.put(b'\n');
}
}
pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
let mut first = true;
for e in iter {
if first {
first = false;
} else {
self.put(b' ');
}
e.write(self);
}
}
pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
let mut first = true;
for e in iter {
if first {
first = false;
} else {
self.put(b' ');
}
e.write(self);
}
}
}
impl Write for Output {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let mut start = 0usize;
let mut rem = buf.len();
while rem > 0 {
let len = (self.buf.len() - self.at).min(rem);
self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
self.at += len;
if self.at == self.buf.len() {
self.flush();
}
start += len;
rem -= len;
}
if self.auto_flush {
self.flush();
}
Ok(buf.len())
}
fn flush(&mut self) -> std::io::Result<()> {
self.flush();
Ok(())
}
}
pub trait Writable {
fn write(&self, output: &mut Output);
}
impl Writable for &str {
fn write(&self, output: &mut Output) {
output.write_all(self.as_bytes()).unwrap();
}
}
impl Writable for String {
fn write(&self, output: &mut Output) {
output.write_all(self.as_bytes()).unwrap();
}
}
impl Writable for char {
fn write(&self, output: &mut Output) {
output.put(*self as u8);
}
}
impl<T: Writable> Writable for [T] {
fn write(&self, output: &mut Output) {
output.print_iter_ref(self.iter());
}
}
impl<T: Writable> Writable for Vec<T> {
fn write(&self, output: &mut Output) {
self[..].write(output);
}
}
macro_rules! write_to_string {
($t:ident) => {
impl Writable for $t {
fn write(&self, output: &mut Output) {
self.to_string().write(output);
}
}
};
}
write_to_string!(u8);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(f64);
impl<T: Writable, U: Writable> Writable for (T, U) {
fn write(&self, output: &mut Output) {
self.0.write(output);
output.put(b' ');
self.1.write(output);
}
}
impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
fn write(&self, output: &mut Output) {
self.0.write(output);
output.put(b' ');
self.1.write(output);
output.put(b' ');
self.2.write(output);
}
}
}
}
pub mod misc {
pub mod binary_search {
use crate::algo_lib::misc::num_traits::Number;
use std::ops::Range;
pub fn binary_search_first_true<T>(range: Range<T>, mut f: impl FnMut(T) -> bool) -> T
where
T: Number,
{
// we can't store [range.start - 1] into [left], because it could overflow
let mut left_plus_one = range.start;
let mut right = range.end;
while right > left_plus_one {
let mid = left_plus_one + (right - left_plus_one) / T::TWO;
if f(mid) {
right = mid;
} else {
left_plus_one = mid + T::ONE;
}
}
right
}
pub fn binary_search_last_true<T>(range: Range<T>, mut f: impl FnMut(T) -> bool) -> Option<T>
where
T: Number,
{
let first_false = binary_search_first_true(range.clone(), |x| !f(x));
if first_false == range.start {
None
} else {
Some(first_false - T::ONE)
}
}
#[test]
fn simple_stress() {
const N: usize = 50;
for n in 1..N {
for cnt_false in 0..=n {
let mut a = vec![false; cnt_false];
a.resize(n, true);
let mut max_f_calls = ((n + 1) as f64).log2().ceil() as i32;
let f_is_true = |id: usize| -> bool {
max_f_calls -= 1;
assert!(max_f_calls >= 0);
a[id]
};
let result = binary_search_first_true(0..n, f_is_true);
assert_eq!(result, cnt_false);
}
}
}
}
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
($first_val:expr, $($val:expr),+ $(,)?) => {
eprint!("[{}:{}] {} = {:?}",
file!(), line!(), stringify!($first_val), &$first_val);
($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
eprintln!();
};
($first_val:expr) => {
eprintln!("[{}:{}] {} = {:?}",
file!(), line!(), stringify!($first_val), &$first_val)
};
}
}
pub mod num_traits {
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;
pub trait HasConstants<T> {
const MAX: T;
const MIN: T;
const ZERO: T;
const ONE: T;
const TWO: T;
}
pub trait ConvSimple<T> {
fn from_i32(val: i32) -> T;
fn to_i32(self) -> i32;
fn to_f64(self) -> f64;
}
pub trait Signum {
fn signum(&self) -> i32;
}
pub trait Number:
Copy
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ PartialOrd
+ PartialEq
+ HasConstants<Self>
+ Default
+ Debug
+ Sized
+ ConvSimple<Self>
{
}
impl<
T: Copy
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ PartialOrd
+ PartialEq
+ HasConstants<Self>
+ Default
+ Debug
+ Sized
+ ConvSimple<Self>,
> Number for T
{
}
macro_rules! has_constants_impl {
($t: ident) => {
impl HasConstants<$t> for $t {
// TODO: remove `std` for new rust version..
const MAX: $t = std::$t::MAX;
const MIN: $t = std::$t::MIN;
const ZERO: $t = 0;
const ONE: $t = 1;
const TWO: $t = 2;
}
impl ConvSimple<$t> for $t {
fn from_i32(val: i32) -> $t {
val as $t
}
fn to_i32(self) -> i32 {
self as i32
}
fn to_f64(self) -> f64 {
self as f64
}
}
};
}
has_constants_impl!(i32);
has_constants_impl!(i64);
has_constants_impl!(i128);
has_constants_impl!(u32);
has_constants_impl!(u64);
has_constants_impl!(u128);
has_constants_impl!(usize);
has_constants_impl!(u8);
impl ConvSimple<Self> for f64 {
fn from_i32(val: i32) -> Self {
val as f64
}
fn to_i32(self) -> i32 {
self as i32
}
fn to_f64(self) -> f64 {
self
}
}
impl HasConstants<Self> for f64 {
const MAX: Self = Self::MAX;
const MIN: Self = -Self::MAX;
const ZERO: Self = 0.0;
const ONE: Self = 1.0;
const TWO: Self = 2.0;
}
impl<T: Number + Ord> Signum for T {
fn signum(&self) -> i32 {
match self.cmp(&T::ZERO) {
Ordering::Greater => 1,
Ordering::Less => -1,
Ordering::Equal => 0,
}
}
}
}
}
}
fn main() {
let input = algo_lib::io::input::Input::new_stdin();
let mut output = algo_lib::io::output::Output::new_stdout();
crate::solution::run(input, output);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 2152kb
input:
8 4 2 1 4 3 4 1 4 2 3 4 3 1 4 2 5 1 3 5 2 4 5 1 4 2 5 3 5 2 5 3 1 4 6 1 3 6 5 2 4 6 2 5 1 3 6 4
output:
3 3 2 3 3 3 4 4
result:
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8 8 8 8 8 8 7 8 8 7 8 8 8 8 8 8 8 8 8 9 7 8 8 8 7 7 7 9 8 8 8 7 8 8 7 8 7 8 8 ...
result:
ok 10000 numbers
Test #10:
score: 0
Accepted
time: 57ms
memory: 2140kb
input:
1000 100 36 19 15 23 80 24 92 12 63 82 17 71 52 53 62 37 30 5 87 14 27 42 47 38 67 39 40 77 6 11 22 58 83 26 86 50 64 54 81 89 60 85 74 55 96 100 2 32 75 49 93 51 41 57 68 10 3 95 79 21 98 69 99 20 56 91 59 76 28 94 66 44 46 70 43 97 7 16 48 29 84 61 9 65 13 31 34 45 33 1 73 72 78 35 88 90 4 25 8 18...
output:
83 82 85 82 82 81 82 82 83 82 81 82 81 83 83 80 83 84 83 84 80 81 80 81 80 82 84 82 84 84 84 83 84 83 84 82 82 86 82 82 83 82 80 82 82 81 81 82 80 80 83 81 83 82 85 83 84 84 83 81 82 81 80 84 84 81 82 83 84 84 84 82 82 83 83 82 82 84 81 80 80 82 81 82 84 84 79 83 83 82 84 81 81 81 84 84 85 83 84 82 ...
result:
ok 1000 numbers
Test #11:
score: 0
Accepted
time: 564ms
memory: 2232kb
input:
100 1000 550 971 302 95 28 284 617 922 674 216 841 488 304 342 88 271 306 556 106 206 22 722 319 730 603 112 877 59 910 921 490 973 35 323 495 9 507 869 834 542 391 86 359 69 837 830 498 645 852 974 790 766 255 98 269 231 452 720 728 925 652 214 91 484 878 592 217 763 487 400 868 66 328 195 923 955 ...
output:
822 826 827 836 825 819 833 828 819 825 826 829 825 828 827 823 826 832 827 822 826 833 824 827 819 821 819 824 830 815 833 831 822 828 835 829 827 824 836 829 822 833 823 830 823 825 823 828 835 827 823 821 831 826 826 822 826 822 831 836 825 829 832 833 825 830 828 822 827 820 831 840 826 827 830 ...
result:
ok 100 numbers
Test #12:
score: -100
Time Limit Exceeded
input:
10 10000 4850 5255 5139 5540 1874 1076 4021 6824 4366 2054 2715 278 8256 4808 9269 3125 6278 690 6792 1562 3953 8690 6144 7653 8183 215 8338 6985 2329 6752 4704 3988 4919 9621 7203 1326 1144 8757 8689 7857 5536 9109 6881 1575 9834 8480 3599 2264 6399 7509 1483 6113 4446 9198 3827 5026 9359 1920 2 58...