結果

問題 No.938 賢人を探せ
ユーザー tonyu0tonyu0
提出日時 2019-12-25 23:26:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 5,415 ms
コンパイル使用メモリ 158,152 KB
実行使用メモリ 6,888 KB
最終ジャッジ日時 2023-08-21 03:42:32
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
6,888 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 11 ms
4,732 KB
testcase_09 AC 11 ms
4,756 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 12 ms
4,724 KB
testcase_12 AC 13 ms
4,812 KB
testcase_13 AC 13 ms
4,520 KB
testcase_14 AC 12 ms
4,652 KB
testcase_15 AC 13 ms
4,724 KB
testcase_16 AC 13 ms
4,660 KB
testcase_17 AC 13 ms
4,660 KB
testcase_18 AC 13 ms
4,648 KB
testcase_19 AC 13 ms
4,676 KB
testcase_20 AC 13 ms
4,700 KB
testcase_21 AC 12 ms
4,604 KB
testcase_22 AC 43 ms
6,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = std::collections::HashMap::new();
    let mut check = std::collections::HashMap::new();
    let mut name = Vec::new();
    for _ in 0..n {
        let from = itr.next().unwrap();
        let to = itr.next().unwrap();
        let num = ans.entry(from).or_insert(0);
        check.entry(from).or_insert(false);
        check.entry(to).or_insert(false);
        name.push(to);
        *num += 1;
        ans.entry(to).or_insert(0);
    }
    for &i in name.iter() {
        if !check[i] && ans[i] == 0 {
            println!("{}", i);
            check.insert(i, true);
        }
    }
}
0