結果

問題 No.1053 ゲーミング棒
ユーザー fukafukatanifukafukatani
提出日時 2020-05-15 21:45:09
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,098 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 174,712 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 13:18:38
合計ジャッジ時間 1,806 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 AC 1 ms
4,348 KB
testcase_15 RE -
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 RE -
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 0 ms
4,348 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 6 ms
4,348 KB
testcase_25 AC 6 ms
4,348 KB
testcase_26 WA -
testcase_27 RE -
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<usize>();
    v.dedup();
    let mut exist = vec![false; 100001];

    let mut count = 0;
    for i in 0..n {
        if exist[v[i]] {
            count += 1;
        }
        exist[v[i]] = true;
    }

    if count == 0 {
        println!("0");
    } else if count == 1 {
        println!("1");
    } else {
        println!("-1");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0