結果
問題 | No.938 賢人を探せ |
ユーザー | tonyu0 |
提出日時 | 2019-12-25 23:26:42 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 829 bytes |
コンパイル時間 | 12,813 ms |
コンパイル使用メモリ | 405,240 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 11:55:39 |
合計ジャッジ時間 | 14,234 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
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); } } }