結果
問題 | No.2910 単体ホモロジー入門 |
ユーザー |
|
提出日時 | 2024-10-04 22:38:22 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,140 bytes |
コンパイル時間 | 17,319 ms |
コンパイル使用メモリ | 382,344 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 22:38:40 |
合計ジャッジ時間 | 17,860 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 WA * 2 |
ソースコード
use proconio::input;fn main() {println!("{}", if solve() { "Yes" } else { "No" });}fn solve() -> bool {input! {(n, m): (usize, usize),ij: [(usize, usize); m],mut vv: [usize; 3],}vv.sort_unstable();vv.dedup();if vv.len() == 1 {return true;}let mut graph = vec![vec![]; n];for &(u, v) in &ij {graph[u].push(v);graph[v].push(u);}let mut stack = (0..n).map(|i| vec![i]).collect::<Vec<_>>();while let Some(path) = stack.pop() {let cur = *path.last().unwrap();for &next in &graph[cur] {if path.len() >= 3 && next == path[0] {let mut nodes = path.clone();nodes.sort_unstable();nodes.dedup();if nodes != vv {return true;}continue;}if path.contains(&next) {continue;}let mut next_path = path.clone();next_path.push(next);stack.push(next_path);}}false}