File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/main/java/com/lzw/solutions/codeforces/p2190A Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 44import java .io .IOException ;
55import java .io .InputStreamReader ;
66import java .io .PrintWriter ;
7+ import java .util .ArrayList ;
8+ import java .util .Arrays ;
79
810public class Main {
911
@@ -41,6 +43,24 @@ void solve() throws IOException {
4143 out .println ("Bob" );
4244 } else {
4345 out .println ("Alice" );
46+ char [] chars = s .toCharArray ();
47+ char [] sortedChars = chars .clone ();
48+ Arrays .sort (sortedChars );
49+ ArrayList <Integer > positions = new ArrayList <>();
50+ for (i = 0 ; i < n ; i ++) {
51+ if (chars [i ] != sortedChars [i ]) {
52+ positions .add (i );
53+ }
54+ }
55+ int size = positions .size ();
56+ out .println (size );
57+ for (i = 0 ; i < size ; i ++) {
58+ if (i != 0 ) {
59+ out .print (' ' );
60+ }
61+ out .print (positions .get (i ) + 1 );
62+ }
63+ out .println ();
4464 }
4565 }
4666 }
You can’t perform that action at this time.
0 commit comments