結果
問題 | No.2948 move move rotti |
ユーザー | strangerxxx |
提出日時 | 2024-10-28 13:59:14 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 7,121 bytes |
コンパイル時間 | 13,278 ms |
コンパイル使用メモリ | 405,704 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-28 13:59:30 |
合計ジャッジ時間 | 14,883 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,820 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
6,820 KB |
testcase_10 | WA | - |
testcase_11 | AC | 1 ms
6,816 KB |
testcase_12 | AC | 1 ms
6,820 KB |
testcase_13 | WA | - |
testcase_14 | AC | 1 ms
6,816 KB |
testcase_15 | AC | 1 ms
6,820 KB |
testcase_16 | AC | 1 ms
6,816 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | AC | 1 ms
6,816 KB |
testcase_19 | AC | 1 ms
6,820 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 1 ms
6,816 KB |
testcase_27 | AC | 1 ms
6,816 KB |
testcase_28 | AC | 1 ms
6,816 KB |
testcase_29 | AC | 1 ms
6,816 KB |
testcase_30 | AC | 1 ms
6,816 KB |
ソースコード
// -*- coding:utf-8-unix -*- #![allow(dead_code, unused_imports, unused_macros)] fn main() { input! { n: usize, m: usize, k: usize, x: [usize1; k], edge: [(usize1, usize1); m], } let mut edges = vec![vec![]; n]; for (u, v) in edge { edges[u].push(v); edges[v].push(u); } let mut dists = vec![!0usize; n]; let mut q = vec![x[0]]; dists[x[0]] = 0; while let Some(i) = q.pop() { for &j in &edges[i] { if dists[j] != !0 { if (dists[i] + dists[j]) % 2 == 0 { p!("Yes"); return; } } else { dists[j] = dists[i] + 1; q.push(j); } } } for i in x { if dists[i] % 2 != 0 { p!("No"); return; } } p!("Yes"); } // use ::num; // use itertools::Itertools; // use ac_library::*; // use proconio::input; use cmp::Ordering::*; // use itertools::Itertools; // use itertools_num::ItertoolsNum; // use maplit; // use ordered_float::OrderedFloat; use std::cmp::*; use std::collections::*; use std::fmt::*; use std::hash::*; use std::io::{stdin, stdout, Write}; use std::iter::FromIterator; use std::str::FromStr; use std::*; // use superslice::*; // use rand::Rng; // use rand::rngs::SmallRng; // use rand::seq::SliceRandom; const MOD1000000007: i64 = 1000000007; const MOD998244353: i64 = 998244353; const MOD: i64 = 998244353; const UMOD: usize = MOD as usize; const PI: f64 = f64::consts::PI; const DIRS: [char; 4] = ['U', 'D', 'L', 'R']; const DIJ: [(usize, usize); 4] = [(!0, 0), (1, 0), (0, !0), (0, 1)]; #[macro_export] macro_rules! p { ($($arg:expr),*) => { { print!("{}\n", vec![$(format!("{}", $arg)),*].join(" ")); } }; } #[macro_export] macro_rules! vp { ($x:expr) => { print!( "{}\n", $x.iter() .map(|x| x.to_string()) .collect::<Vec<_>>() .join(" ") ); }; } #[macro_export] macro_rules! dprint { ($($arg:expr),*) => { #[allow(unused_assignments)] { let mut first = true; $( if !first { eprint!(" "); } eprint!("{:?}", $arg); first = false; )* eprint!("\n"); } }; } #[macro_export] macro_rules! yesno { ($val:expr) => { if $val { print!("Yes\n"); } else { print!("No\n"); } }; } fn read<T: FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn read_mat<T: FromStr>(n: usize) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } fn readii() -> (i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1]) } fn readiii() -> (i64, i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1], vec[2]) } fn readuu() -> (usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1]) } fn readff() -> (f64, f64) { let vec: Vec<f64> = read_vec(); (vec[0], vec[1]) } fn readcc() -> (char, char) { let vec: Vec<char> = read_vec(); (vec[0], vec[1]) } fn readuuu() -> (usize, usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1], vec[2]) } fn readiiii() -> (i64, i64, i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1], vec[2], vec[3]) } fn readuuuu() -> (usize, usize, usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1], vec[2], vec[3]) } #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[macro_export] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } pub trait BinarySearch<T> { fn bisect_left(&self, key: T) -> usize; fn bisect_right(&self, key: T) -> usize; } impl<T> BinarySearch<T> for [T] where T: Ord, { fn bisect_left(&self, key: T) -> usize { let mut ng = -1 as isize; let mut ok = self.len() as isize; while ok - ng > 1 { let mid = (ok + ng) / 2; if key <= self[mid as usize] { ok = mid; } else { ng = mid; } } ok as usize } fn bisect_right(&self, key: T) -> usize { let mut ng = -1 as isize; let mut ok = self.len() as isize; while ok - ng > 1 { let mid = (ok + ng) / 2; if key < self[mid as usize] { ok = mid; } else { ng = mid; } } ok as usize } } pub fn next_permutation<T: Ord>(a: &mut [T]) -> bool { let Some(i) = a.windows(2).rposition(|w| w[0] < w[1]) else { return false; }; let j = a.iter().rposition(|x| x > &a[i]).unwrap(); a.swap(i, j); a[i + 1..].reverse(); true } fn mod_pow<T>(x: T, a: T, md: T) -> T where T: Copy + From<u8> + std::ops::Mul<Output = T> + std::ops::Rem<Output = T> + std::ops::Shr<u64, Output = T> + std::ops::Add<Output = T> + std::ops::BitAnd<Output = T> + PartialOrd + Default + std::ops::ShrAssign<i32>, { let mut res = T::from(1); let mut base = x; let mut ai = a; while ai > T::from(0) { if ai & T::from(1) == T::from(1) { res = res * base % md; } ai >>= 1; base = (base * base) % md; } res }