結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2022-12-24 22:32:04 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 13,049 ms |
コンパイル使用メモリ | 399,832 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 05:37:49 |
合計ジャッジ時間 | 14,319 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
use std::collections::{BTreeSet, HashMap};fn main() {let mut xx = String::new();std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();let xx: Vec<usize> = xx.split_whitespace().flat_map(str::parse).collect();let n = xx[0];let m = xx[1];let mut e = vec![HashMap::<usize, Vec<_>>::new(); n + 1];for x in xx[3..3 * (m + 1)].chunks(3) {e[x[0]].entry(x[2]).or_default().push(x[1]);e[x[1]].entry(x[2]).or_default().push(x[0]);}let mut pp: BTreeSet<usize> = (1..=n).collect();for &k in &xx[3 * (m + 1)..] {let mut new_pp = BTreeSet::new();for &p in &pp {if let Some(v) = e[p].get(&k) {new_pp.extend(v);}}pp = new_pp;}let output = pp.iter().map(|&p| p.to_string()).collect::<Vec<String>>();println!("{}", pp.len());println!("{}", output.join(" "));}