結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー tipstar0125tipstar0125
提出日時 2023-05-20 15:15:44
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 5,364 bytes
コンパイル時間 15,635 ms
コンパイル使用メモリ 379,036 KB
実行使用メモリ 31,412 KB
最終ジャッジ日時 2024-06-01 07:13:29
合計ジャッジ時間 24,139 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 201 ms
16,696 KB
testcase_15 WA -
testcase_16 AC 198 ms
16,824 KB
testcase_17 AC 199 ms
16,824 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 200 ms
16,696 KB
testcase_21 AC 225 ms
31,408 KB
testcase_22 AC 222 ms
31,284 KB
testcase_23 AC 223 ms
31,336 KB
testcase_24 AC 223 ms
31,284 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 224 ms
31,412 KB
testcase_28 AC 226 ms
31,288 KB
testcase_29 WA -
testcase_30 AC 222 ms
31,408 KB
testcase_31 AC 122 ms
31,280 KB
testcase_32 AC 124 ms
31,288 KB
testcase_33 AC 126 ms
31,408 KB
testcase_34 AC 140 ms
31,280 KB
testcase_35 AC 139 ms
31,280 KB
testcase_36 WA -
testcase_37 AC 10 ms
5,376 KB
testcase_38 AC 196 ms
16,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::comparison_chain)]
#![allow(clippy::nonminimal_bool)]
#![allow(clippy::neg_multiply)]
#![allow(dead_code)]
// use itertools::Itertools;
// use superslice::Ext;
use std::cmp::Reverse;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

#[derive(Default)]
struct Solver {}
impl Solver {
    fn solve(&mut self) {
        input! {
            T: usize,
        }

        let f = |a: bool, b: bool, e: &String| -> bool {
            if e.as_str() == "and" {
                a & b
            } else if e.as_str() == "or" {
                a | b
            } else if e.as_str() == "xor" {
                a ^ b
            } else if a {
                b
            } else {
                true
            }
        };

        for _ in 0..T {
            input! {
                N: usize,
                X: [String; N],
                Y: [String; N - 1],
                S: [usize1; N - 1]
            }

            let mut X: Vec<bool> = X.iter().map(|x| x.as_str() == "True").collect();

            let mut set_u: BTreeSet<usize> = (0..N).collect();
            let mut set_v: BTreeSet<usize> = (0..N - 1).collect();

            let mut ans = true;

            for &s in &S {
                let pos_u0 = *set_u.range(s..).next().unwrap();
                let pos_u1 = *set_u.range(pos_u0 + 1..).next().unwrap();
                set_u.remove(&pos_u1);
                let pos_v = *set_v.range(pos_u0..).next().unwrap();
                set_v.remove(&pos_v);

                ans = f(X[pos_u0], X[pos_u1], &Y[pos_v]);
                X[pos_u0] = ans;
                // X[pos_u1] = ans;
            }

            if ans {
                println!("True");
            } else {
                println!("False");
            }
        }
    }
}

#[macro_export]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $( $y: expr ),+) => {
        std::cmp::max($x, max!($( $y ),+))
    }
}
#[macro_export]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $( $y: expr ),+) => {
        std::cmp::min($x, min!($( $y ),+))
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(128 * 1024 * 1024)
        .spawn(|| Solver::default().solve())
        .unwrap()
        .join()
        .unwrap();
}

#[macro_export]
macro_rules! input {
    () => {};
    (mut $var:ident: $t:tt, $($rest:tt)*) => {
        let mut $var = __input_inner!($t);
        input!($($rest)*)
    };
    ($var:ident: $t:tt, $($rest:tt)*) => {
        let $var = __input_inner!($t);
        input!($($rest)*)
    };
    (mut $var:ident: $t:tt) => {
        let mut $var = __input_inner!($t);
    };
    ($var:ident: $t:tt) => {
        let $var = __input_inner!($t);
    };
}

#[macro_export]
macro_rules! __input_inner {
    (($($t:tt),*)) => {
        ($(__input_inner!($t)),*)
    };
    ([$t:tt; $n:expr]) => {
        (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
    };
    ([$t:tt]) => {{
        let n = __input_inner!(usize);
        (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
    }};
    (chars) => {
        __input_inner!(String).chars().collect::<Vec<_>>()
    };
    (bytes) => {
        __input_inner!(String).into_bytes()
    };
    (usize1) => {
        __input_inner!(usize) - 1
    };
    ($t:ty) => {
        $crate::read::<$t>()
    };
}

#[macro_export]
macro_rules! println {
    () => {
        $crate::write(|w| {
            use std::io::Write;
            std::writeln!(w).unwrap()
        })
    };
    ($($arg:tt)*) => {
        $crate::write(|w| {
            use std::io::Write;
            std::writeln!(w, $($arg)*).unwrap()
        })
    };
}

#[macro_export]
macro_rules! print {
    ($($arg:tt)*) => {
        $crate::write(|w| {
            use std::io::Write;
            std::write!(w, $($arg)*).unwrap()
        })
    };
}

#[macro_export]
macro_rules! flush {
    () => {
        $crate::write(|w| {
            use std::io::Write;
            w.flush().unwrap()
        })
    };
}

pub fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::cell::RefCell;
    use std::io::*;

    thread_local! {
        pub static STDIN: RefCell<StdinLock<'static>> = RefCell::new(stdin().lock());
    }

    STDIN.with(|r| {
        let mut r = r.borrow_mut();
        let mut s = vec![];
        loop {
            let buf = r.fill_buf().unwrap();
            if buf.is_empty() {
                break;
            }
            if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {
                s.extend_from_slice(&buf[..i]);
                r.consume(i + 1);
                if !s.is_empty() {
                    break;
                }
            } else {
                s.extend_from_slice(buf);
                let n = buf.len();
                r.consume(n);
            }
        }
        std::str::from_utf8(&s).unwrap().parse().unwrap()
    })
}

pub fn write<F>(f: F)
where
    F: FnOnce(&mut std::io::BufWriter<std::io::StdoutLock>),
{
    use std::cell::RefCell;
    use std::io::*;

    thread_local! {
        pub static STDOUT: RefCell<BufWriter<StdoutLock<'static>>> =
            RefCell::new(BufWriter::new(stdout().lock()));
    }

    STDOUT.with(|w| f(&mut w.borrow_mut()))
}
0