結果

問題 No.2343 (l+r)/2
ユーザー koba-e964koba-e964
提出日時 2023-06-13 01:07:43
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,280 bytes
コンパイル時間 3,604 ms
コンパイル使用メモリ 161,064 KB
実行使用メモリ 11,896 KB
最終ジャッジ日時 2023-09-02 17:47:01
合計ジャッジ時間 5,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn f(mut a: Vec<i32>) -> bool {
    let mut s = [0; 2];
    for i in 0..a.len() {
        s[a[i] as usize] += 1;
    }
    a.dedup();
    let m = a.len();
    if m % 2 == 0 { return true; }
    if a[0] == 0 && s[1] == m / 2 {
        return false;
    }
    if a[0] == 1 && s[0] == m / 2 {
        return false;
    }
    true
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););}
    input!(a: [[i32]]);
    for a in a {
        puts!("{}\n", if f(a) { "Yes" } else { "No" });
    }
}
0