/* -*- coding: utf-8 -*- * * 3143.cc: No.3143 Colorless Green Parentheses Sleep Furiously - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_M = MAX_N * 5; /* typedef */ using sti = stack; /* global variables */ char s[MAX_N + 4], t[MAX_M + 4]; /* subroutines */ /* main */ int main() { int n, k; scanf("%d%d%s", &n, &k, s); sti q; int f = 0, m = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') { if (! q.empty()) q.top() = 1; q.push(2); if (i > 0 && s[i - 1] == ')') t[m++] = '+'; t[m++] = '('; } else { if (q.empty()) { puts("No"); return 0; } int d = q.top(); q.pop(); f += d; if (d > 1) t[m++] = '1'; t[m++] = '+', t[m++] = '1', t[m++] = ')'; } } if (! q.empty() || f > k) { puts("No"); return 0; } while (f < k) t[m++] = '+', t[m++] = '1', f++; t[m] = '\0'; puts("Yes"); puts(t); return 0; }