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