Submission #2667154
Source Code Expand
#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::{max, min, Ordering}; use std::collections::*; use std::io::*; use std::ops::*; use std::*; // ----------------------------------------------- // Framework // ----------------------------------------------- #[allow(unused)] fn rl() -> String { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); buf.trim_right().to_owned() } #[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => { (0..$n).map(|_| read!([$t])).collect::<Vec<_>>() }; ($($t:ty),+ ; $n:expr) => { (0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>() }; ([$t:ty]) => {{ rl() .split_whitespace() .map(|word| word.parse().unwrap()) .collect::<Vec<$t>>() }}; ($t:ty) => { rl().parse::<$t>().unwrap() }; ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace().into_iter(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } // ----------------------------------------------- // Solution // ----------------------------------------------- pub fn recurse<X, Y, F: FnMut(&mut FnMut(X) -> Y, X) -> Y>(x: X, mut f: F) -> Y { fn call<X, Y>(x: X, f: &mut FnMut(&mut FnMut(X) -> Y, X) -> Y) -> Y { let fp = f as *mut FnMut(&mut FnMut(X) -> Y, X) -> Y; let f1 = unsafe { &mut *fp }; let f2 = unsafe { &mut *fp }; f1(&mut |x: X| call(x, f2), x) } call(x, &mut f) } pub fn main() { let (N, M) = read!(usize, usize); let mut g = vec![vec![]; N + M]; for v in 0..N { let w = read!([usize]); for &w in &w[1..] { g[v].push(N + w - 1); g[N + w - 1].push(v); } } let mut done = vec![false; N + M]; recurse(0, |go, v| { if done[v] { return; } done[v] = true; for &w in g[v].iter() { go(w); } }); println!("{}", if (0..N).all(|v| done[v]) { "YES" } else { "NO" }); return; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | vain0 |
Language | Rust (1.15.1) |
Score | 400 |
Code Size | 2158 Byte |
Status | AC |
Exec Time | 45 ms |
Memory | 14588 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 200 / 200 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
dataset1 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
dataset2 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 4352 KB |
01-02.txt | AC | 2 ms | 4352 KB |
01-03.txt | AC | 2 ms | 4352 KB |
01-04.txt | AC | 2 ms | 4352 KB |
01-05.txt | AC | 2 ms | 4352 KB |
01-06.txt | AC | 2 ms | 4352 KB |
01-07.txt | AC | 2 ms | 4352 KB |
01-08.txt | AC | 2 ms | 4352 KB |
01-09.txt | AC | 2 ms | 4352 KB |
01-10.txt | AC | 2 ms | 4352 KB |
02-01.txt | AC | 22 ms | 11132 KB |
02-02.txt | AC | 42 ms | 12668 KB |
02-03.txt | AC | 22 ms | 9724 KB |
02-04.txt | AC | 45 ms | 10492 KB |
02-05.txt | AC | 44 ms | 11388 KB |
02-06.txt | AC | 38 ms | 10492 KB |
02-07.txt | AC | 42 ms | 12540 KB |
02-08.txt | AC | 36 ms | 12540 KB |
02-09.txt | AC | 41 ms | 14588 KB |
02-10.txt | AC | 27 ms | 12540 KB |
02-11.txt | AC | 27 ms | 12540 KB |
02-12.txt | AC | 28 ms | 12540 KB |
02-13.txt | AC | 29 ms | 12540 KB |
sample-01.txt | AC | 2 ms | 4352 KB |
sample-02.txt | AC | 2 ms | 4352 KB |