mod my { #[macro_export] macro_rules! scan { ($sc:expr, [$t:tt; $n:expr]) => ( (0..$n).map(|_| scan!($sc, $t)).collect::>() ); ($sc:expr, ($($t:tt),*)) => (($(scan!($sc, $t)),*)); ($sc:expr, Usize1) => (scan!($sc, usize) - 1); ($sc:expr, Bytes) => ($sc.next().as_bytes().to_vec()); ($sc:expr, Chars) => ($sc.next().chars().collect::>()); ($sc:expr, $t:ty) => ($sc.next().parse::<$t>().unwrap()); } pub mod io { use std::io::{BufRead, ErrorKind}; fn scan(r: &mut R, buf: &mut Vec) { loop { let (done, used) = { let available = match r.fill_buf() { Ok(n) => n, Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => panic!(e), }; match available.iter().position(u8::is_ascii_whitespace) { Some(i) => { buf.extend_from_slice(&available[..i]); (buf.len() > 0, i + 1) } None => { buf.extend_from_slice(available); (false, available.len()) } } }; r.consume(used); if done || used == 0 { return; } } } pub struct Scanner { r: R, buf: Vec } impl Scanner { pub fn new(r: R) -> Self { Self { r, buf: Vec::new() } } pub fn next(&mut self) -> &str { self.buf.clear(); scan(&mut self.r, &mut self.buf); std::str::from_utf8(&self.buf).unwrap() } } } } use std::io::{BufRead, Write}; use my::io::Scanner; fn run(sc: &mut Scanner, wr: &mut W) { let (n, m) = scan!(sc, (usize, usize)); let a = scan!(sc, [Usize1; n]); let mut g = vec![vec![]; m]; let mut d = vec![0; m]; for i in 0..n { if i > 0 && i + 1 < n && a[i - 1] == a[i + 1] { writeln!(wr, "No").ok(); return; } if i % 2 == 1 { continue; } if i > 0 { g[a[i]].push(a[i - 1]); d[a[i - 1]] += 1; } if i + 1 < n { g[a[i]].push(a[i + 1]); d[a[i + 1]] += 1; } } let mut c = 1; let mut ans = vec![0; m]; let mut stack = Vec::new(); for i in 0..m { if d[i] == 0 { ans[i] = c; c += 1; stack.push(i); } } while let Some(from) = stack.pop() { for &to in &g[from] { d[to] -= 1; if d[to] == 0 { ans[to] = c; c += 1; stack.push(to); } } } if ans.iter().all(|i| *i > 0) { writeln!(wr, "Yes").ok(); write!(wr, "{}", ans[0]).ok(); for i in ans.iter().skip(1) { write!(wr, " {}", i).ok(); } writeln!(wr).ok(); } else { writeln!(wr, "No").ok(); } } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let sc = &mut Scanner::new(std::io::BufReader::new(stdin.lock())); let wr = &mut std::io::BufWriter::new(stdout.lock()); run(sc, wr); }