Oh, I didn't do it.
#include <cstdio> #include <cstring> #include <algorithm>const int N = 1000000 + 10;char s[n];int d[n], nu M[n];int Main () {while (~SCANF ("%s", s)) {memset (num, 0, sizeof num); int len = strlen (s); int f = 1, v = 0; for (int i = 0; i < len; ++i) {if (s[i] = = ' (' | | s[i] = = '?') + + V; else--V; D[i] = v; if (v < 0) {f = 0; Break }} if ((Len & 1) | | (D[len-1] & 1)) f = 0; else if (f && d[len-1]! = 0) {for (int i = len-2; I >= 0; i) d[i] = Std::min (d [i], d[i + 1]); v = d[len-1]/2; int cnt = 0; for (int i = 0; i < len && cnt = v; ++i) {if (s[i]! = '?)
') continue; if (D[i]-2 * (CNT + 1) >= 0) num[i] = ++cnt; } if (cnt! = v) {f = 0; } else {int pre = 1; for (int i = 0; i < len && f! = 2;) {if (Num[i]! = Pre) + + I; else {int J; for (j = i + 1, j < Len; ++j) {if (num[j] = = pre + 1) break; if (s[j]! = '? ') Continue if (D[j]-Pre * 2 >= 0) {f = 2; Break }} i = J; + + pre; }}}} if (f = = 0) puts ("None"); else if (1 = = f) puts ("Unique"); Else puts ("many"); } return 0;}
HDU 4915 Parenthese Sequence _ (: Зゝ∠) _ haha