use std::collections::HashSet; use proconio::{input, marker::Chars}; fn main() { input! { n:usize, m:usize, s:[Chars;m], } let s = s.into_iter().map(|si| to_int(&si)).collect::>(); if !s.contains(&(2usize.pow(n as u32) - 1)) { println!("No"); return; } for &si in s.iter() { for &sj in s.iter() { if !s.contains(&(si & sj)) { println!("No"); return; } } } let mut t = HashSet::new(); t.insert(0); for &si in s.iter() { let mut t_nxt = HashSet::new(); for &ti in t.iter() { t_nxt.insert(si | ti); t_nxt.insert(ti); } t = t_nxt; if t.len() >= 2usize.pow(n as u32) { break; } } let ans = t.iter().all(|&ti| s.contains(&ti)); println!("{}", if ans { "Yes" } else { "No" }); } fn to_int(s: &Vec) -> usize { let mut res = 0; for (i, &d) in s.iter().rev().enumerate() { if d == '1' { res |= 1 << i; } } res }