File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
src/main/java/com/lzw/solutions/codeforces/p2190B1 Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,18 @@ public class Main {
1717 // (())()
1818 // (()(()))
1919 // (()()(()))
20+ // ((())((())))
21+ // (((())))
22+
23+ private static void printArray (int [] array ) {
24+ for (int i = 0 ; i < array .length ; i ++) {
25+ if (i != 0 ) {
26+ out .print (' ' );
27+ }
28+ out .print (array [i ]);
29+ }
30+ out .println ();
31+ }
2032
2133 private static void solve () throws IOException {
2234 int t = Integer .parseInt (in .readLine ());
@@ -28,11 +40,22 @@ private static void solve() throws IOException {
2840 if (n == 2 ) {
2941 ans = -1 ;
3042 } else {
31- if (s .contains ("()((" )) {
32- ans = n - 2 ;
33- } else {
34- ans = -1 ;
43+ // if (s.contains("()((")) {
44+ // ans = n - 2;
45+ // } else {
46+ int [] array = new int [n ];
47+ int acc = 0 ;
48+ for (int i = 0 ; i < n ; i ++) {
49+ if (s .charAt (i ) == '(' ) {
50+ acc --;
51+ } else {
52+ acc ++;
53+ }
54+ array [i ] = acc ;
3555 }
56+ printArray (array );
57+ ans = 0 ;
58+ // }
3659 }
3760 out .println (ans );
3861 }
You can’t perform that action at this time.
0 commit comments