File tree Expand file tree Collapse file tree 6 files changed +18
-18
lines changed
src/main/java/com/lzw/solutions Expand file tree Collapse file tree 6 files changed +18
-18
lines changed Original file line number Diff line number Diff line change 1111 <description >Consolidated project for algorithm solutions from multiple platforms</description >
1212
1313 <properties >
14- <maven .compiler.source>24 </maven .compiler.source>
15- <maven .compiler.target>24 </maven .compiler.target>
14+ <maven .compiler.source>21 </maven .compiler.source>
15+ <maven .compiler.target>21 </maven .compiler.target>
1616 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
1717 <problem >p140</problem >
1818 <codeforcesProblem >p71A</codeforcesProblem >
Original file line number Diff line number Diff line change @@ -43,9 +43,9 @@ private static void solve() throws IOException {
4343 if (n == 2 ) {
4444 ans = -1 ;
4545 } else {
46- // if (s.contains("()((")) {
47- // ans = n - 2;
48- // } else {
46+ // if (s.contains("()((")) {
47+ // ans = n - 2;
48+ // } else {
4949 int [] array = new int [n ];
5050 int acc = 0 ;
5151 for (int i = 0 ; i < n ; i ++) {
@@ -58,7 +58,7 @@ private static void solve() throws IOException {
5858 }
5959 printArray (array );
6060 ans = 0 ;
61- // }
61+ // }
6262 }
6363 out .println (ans );
6464 }
Original file line number Diff line number Diff line change @@ -32,11 +32,11 @@ public static void main(String[] args) {
3232
3333 // now add the changed '('
3434 bal += 1 ;
35- if (bal < 0 ) continue ; // though unlikely here
35+ if (bal < 0 ) continue ; // though unlikely here
3636
3737 // now from i+1 to end, greedily take as far as possible
3838 // while keeping bal >= 0, and stop when bal returns to 0
39- int len = i + 1 ; // 0-based: positions 0..i
39+ int len = i + 1 ; // 0-based: positions 0..i
4040 int startBal = bal ;
4141
4242 for (int j = i + 1 ; j < n ; j ++) {
@@ -46,7 +46,7 @@ public static void main(String[] args) {
4646 if (bal == 0 ) {
4747 // found a valid completion
4848 ans = Math .max (ans , len );
49- break ; // no need to go further — longer won't be prefix-equal
49+ break ; // no need to go further — longer won't be prefix-equal
5050 }
5151 }
5252 }
@@ -55,4 +55,4 @@ public static void main(String[] args) {
5555 }
5656 sc .close ();
5757 }
58- }
58+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public static void main(String[] args) {
1313
1414 int ans = -1 ;
1515
16- for (int split = 1 ; split <= n ; split += 2 ) { // possible lengths of t
16+ for (int split = 1 ; split <= n ; split += 2 ) { // possible lengths of t
1717 // check if we can form a regular seq of length 'split' that is better than s
1818 // i.e. first difference position has ( in t, ) in s
1919
@@ -33,17 +33,17 @@ public static void main(String[] args) {
3333 if (open > 0 ) {
3434 // we could close, but we decide to open instead
3535 foundDiff = true ;
36- open ++; // pretend we put (
36+ open ++; // pretend we put (
3737 } else {
38- open --; // forced to follow s
38+ open --; // forced to follow s
3939 }
4040 }
4141 } else {
4242 // after difference, freely choose to make it valid
4343 if (open > 0 && i + 1 < split ) {
44- open --; // prefer close if possible
44+ open --; // prefer close if possible
4545 } else {
46- open ++; // open
46+ open ++; // open
4747 }
4848 }
4949
@@ -62,4 +62,4 @@ public static void main(String[] args) {
6262 }
6363 sc .close ();
6464 }
65- }
65+ }
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ public static void main(String[] args) throws IOException {
1717 solve ();
1818 out .close ();
1919 }
20- }
20+ }
Original file line number Diff line number Diff line change @@ -34,4 +34,4 @@ public static void main(String[] args) throws IOException {
3434 solve ();
3535 out .close ();
3636 }
37- }
37+ }
You can’t perform that action at this time.
0 commit comments