-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSolution.java
32 lines (25 loc) Β· 927 Bytes
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package Iterations.swea1289;
import java.io.*;
public class Solution {
static int T;
static String input;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws Exception {
System.setIn(new FileInputStream("src/Iterations/swea1289/input.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
T = Integer.parseInt(br.readLine());
for (int t = 1; t <= T; t++) {
sb.append("#").append(t).append(" ");
input = br.readLine();
int cnt = 0;
char cursor = '0';
for (int i = 0; i < input.length(); i++) {
if (input.charAt(i) == cursor) continue;
cursor = (cursor == '0') ? '1' : '0';
cnt ++;
}
sb.append(cnt).append("\n");
}
System.out.println(sb.toString());
}
}