結果
問題 | No.2948 move move rotti |
ユーザー |
![]() |
提出日時 | 2024-10-28 20:54:19 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,780 bytes |
コンパイル時間 | 13,470 ms |
コンパイル使用メモリ | 401,624 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-28 20:54:34 |
合計ジャッジ時間 | 14,724 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 8 |
ソースコード
#![allow(non_snake_case, unused_must_use, unused_imports)] use std::io::{self, prelude::*}; fn main() { let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout()); let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock())); macro_rules! input { ($t: tt, $n: expr) => { (0..$n).map(|_| input!($t)).collect::<Vec<_>>() }; (Chars) => { input! {String}.chars().collect::<Vec<_>>() }; (Usize1) => { stdin.next().unwrap().parse::<usize>().unwrap() - 1 }; ($t: ty) => { stdin.next().unwrap().parse::<$t>().unwrap() }; } let N = input!(usize); let M = input!(usize); let K = input!(usize); let X = input!(Usize1, K); let edges = (0..M) .map(|_| (input!(Usize1), input!(Usize1))) .collect::<Vec<_>>(); let mut graph = vec![vec![]; N]; for (u, v) in edges { graph[u].push(v); graph[v].push(u); } let mut dp = vec![vec![vec![false; N]; N + 1]; K]; for i in 0..K { dp[i][0][X[i]] = true; } for i in 0..K { for j in 0..N { for k in 0..N { if dp[i][j][k] { for &l in graph[k].iter() { dp[i][j + 1][l] = true; } } } } } for i in 0..=N { for j in 0..N { let mut isok = true; for k in 0..K { if !dp[k][i][j] { isok = false; } } if isok { writeln!(buffer, "Yes"); return; } } } writeln!(buffer, "No"); }