結果

問題 No.977 アリス仕掛けの摩天楼
コンテスト
ユーザー phspls
提出日時 2020-01-31 23:40:26
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 994 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,003 ms
コンパイル使用メモリ 195,932 KB
実行使用メモリ 8,288 KB
最終ジャッジ日時 2026-04-06 06:25:27
合計ジャッジ時間 2,133 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let all_data: Vec<&str> = all_data.trim().split('\n').map(|s| s.trim()).collect();
    let n: usize = all_data.iter().next().unwrap().parse().unwrap();
    let mut lsland2bridges: HashMap<usize, usize> = HashMap::new();
    all_data.iter().skip(1).take(n).for_each(|s| {
        s.split_whitespace().map(|i| i.parse::<usize>().unwrap()).for_each(|a| {
            if let Some(x) = lsland2bridges.get_mut(&a) {
                *x += 1;
            } else {
                lsland2bridges.insert(a, 1);
            }
        });
    });
    if lsland2bridges.len() == n {
        println!("Bob");
    } else if lsland2bridges.len() + 1 < n {
        println!("Alice");
    } else {
        if lsland2bridges.values().min().unwrap() == &1 {
            println!("Alice");
        } else {
            println!("Bob");
        }
    }
}
0