#![allow(non_snake_case, unused_imports)] use std::collections::{BinaryHeap, HashMap, HashSet}; use proconio::{input, marker::Usize1, marker::Chars}; use itertools::Itertools; #[allow(unused_macros)] macro_rules! d { ( $( $x:expr ),* $(,)? ) => { eprintln!( concat!( $( stringify!($x), "={:?} " ),* ), $( $x ),* ); }; } #[allow(dead_code)] fn yn(b: bool) -> &'static str { if b { "Yes" } else { "No" } } fn dfs(v: usize, adj: &HashMap>, nodes: &mut Vec) -> bool { if let Some(vs) = adj.get(&v) { for &to in vs.iter() { if to == v { continue } if nodes[to] == -1 { nodes[to] = nodes[v] ^ 1; if !dfs(to, adj, nodes) { return false; } } else if nodes[to] == nodes[v] { return false; } } } true } fn main() { input! { N: usize, M: usize, } let mut adj = HashMap::>::new(); for _ in 0..M { input! { a: Usize1, b: Usize1, } adj.entry(a).or_default().push(b); adj.entry(b).or_default().push(a); } let mut ans = true; let mut nodes = vec![-1; N]; for i in 0..N { if nodes[i] != -1 { continue } nodes[i] = 0; ans &= dfs(i, &adj, &mut nodes); } println!("{}", yn(ans)); }