use proconio::marker::*; use proconio::*; use std::collections::*; type Map = BTreeMap; type Set = BTreeSet; type Deque = VecDeque; type Heap = BinaryHeap; const MOD: u64 = 998_244_353; fn main() { input! { n: usize, k: usize, s: Bytes, } // S が対応がとれた括弧列かどうか。 // S が A + B の形かどうか。 let mut v = 0; let mut t = false; for (i, &c) in s.iter().enumerate() { if c == b'(' { v += 1; } else { if v == 0 { println!("No"); return; } else { v -= 1; if v == 0 && i != n - 1 { t = true; } } } } if v != 0 { println!("No"); return; } // 作ることのできる数字の下界 let mut x = n / 2; for i in 0..n - 1 { if s[i] == b'(' && s[i + 1] == b')' { x += 1; } } if x <= k { if x == k && !t { println!("No"); return; } println!("Yes"); let mut ans = vec![]; for &c in &s { if c == b'(' { if ans.is_empty() || ans.last().unwrap() == &'(' { ans.push('('); } else { ans.push('+'); ans.push('('); } } else { if ans.last().unwrap() == &'(' { ans.push('1'); ans.push('+'); ans.push('1'); ans.push(')'); } else { ans.push('+'); ans.push('1'); ans.push(')'); } } } for _ in 0..k - x { ans.push('+'); ans.push('1'); } println!( "{}", ans.iter() .fold("".to_string(), |acc, a| acc + &a.to_string()) ); } else { println!("No"); } }