File tree Expand file tree Collapse file tree 1 file changed +76
-0
lines changed
src/main/java/com/lzw/solutions/codeforces/p2190A Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .lzw .solutions .codeforces .p2190A ;
2+
3+ import java .io .BufferedReader ;
4+ import java .io .IOException ;
5+ import java .io .InputStreamReader ;
6+ import java .io .PrintWriter ;
7+ import java .util .ArrayList ;
8+
9+ public class MainPro {
10+
11+ BufferedReader in ;
12+ PrintWriter out ;
13+
14+ MainPro () {
15+ in = new BufferedReader (new InputStreamReader (System .in ));
16+ out = new PrintWriter (System .out );
17+ }
18+
19+ void solve () throws IOException {
20+ int t = Integer .parseInt (in .readLine ());
21+ while (t -- > 0 ) {
22+ int n = Integer .parseInt (in .readLine ());
23+ String s = in .readLine ().trim ();
24+ int i ;
25+ int zero = 0 , one = 0 ;
26+ for (i = 0 ; i < n ; i ++) {
27+ if (s .charAt (i ) == '0' ) {
28+ zero ++;
29+ } else {
30+ one ++;
31+ }
32+ }
33+ if (zero == n || one == n ) {
34+ out .println ("Bob" );
35+ } else {
36+ int leftOne = 0 , rightZero = 0 ;
37+ for (i = 0 ; i < n ; i ++) {
38+ if (s .charAt (i ) == '1' ) {
39+ leftOne = i ;
40+ break ;
41+ }
42+ }
43+ for (i = n - 1 ; i >= 0 ; i --) {
44+ if (s .charAt (i ) == '0' ) {
45+ rightZero = i ;
46+ break ;
47+ }
48+ }
49+
50+ if (rightZero < leftOne ) {
51+ out .println ("Bob" );
52+ } else {
53+ out .println ("Alice" );
54+ out .println (2 );
55+ out .println (String .format ("%d %d" , leftOne + 1 , rightZero + 1 ));
56+ }
57+ }
58+ }
59+ }
60+
61+ void close () throws IOException {
62+ if (in != null ) {
63+ in .close ();
64+ }
65+ if (out != null ) {
66+ out .flush ();
67+ out .close ();
68+ }
69+ }
70+
71+ public static void main (String [] args ) throws Exception {
72+ MainPro main = new MainPro ();
73+ main .solve ();
74+ main .close ();
75+ }
76+ }
You can’t perform that action at this time.
0 commit comments