結果

問題 No.2343 (l+r)/2
ユーザー rp523rp523
提出日時 2023-06-09 22:40:31
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,575 bytes
コンパイル時間 988 ms
コンパイル使用メモリ 151,672 KB
実行使用メモリ 5,140 KB
最終ジャッジ日時 2023-08-30 13:48:52
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 282 ms
5,140 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
4,384 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 9 ms
4,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_macros, unused_imports, dead_code)]
use std::any::TypeId;
use std::cmp::{max, min, Ordering, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};

mod procon_reader {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::FromStr;
    pub fn read<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let stdin = std::io::stdin();
        let mut stdin_lock = stdin.lock();
        let mut u8b: [u8; 1] = [0];
        loop {
            let mut buf: Vec<u8> = Vec::with_capacity(16);
            loop {
                let res = stdin_lock.read(&mut u8b);
                if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                    break;
                } else {
                    buf.push(u8b[0]);
                }
            }
            if !buf.is_empty() {
                let ret = String::from_utf8(buf).unwrap();
                return ret.parse().unwrap();
            }
        }
    }
    pub fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| read::<T>()).collect::<Vec<T>>()
    }
    pub fn read_vec_sub1(n: usize) -> Vec<usize> {
        (0..n).map(|_| read::<usize>() - 1).collect::<Vec<usize>>()
    }
    pub fn read_mat<T: std::str::FromStr>(h: usize, w: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..h).map(|_| read_vec::<T>(w)).collect::<Vec<Vec<T>>>()
    }
}
use procon_reader::*;
/*************************************************************************************
*************************************************************************************/

fn main() {
    let mut ans = vec![];
    for _ in 0..read::<usize>() {
        let n = read::<usize>();
        let a = read_vec::<usize>(n);
        let mut c = vec![];
        let mut z = 0;
        let mut o = 0;
        for &a in &a {
            if c.is_empty() {
                c.push(a);
            } else if c.iter().next_back().unwrap() != &a {
                c.push(a);
            }
            if a == 0 {
                z += 1;
            } else {
                o += 1;
            }
        }
        if c.len() % 2 == 0 {
            ans.push("Yes");
        } else if z == o {
            ans.push("Yes");
        } else {
            ans.push("No");
        }
    }
    eprintln!();
    for ans in ans {
        println!("{}", ans);
    }
}
0