fork download
  1. import java.io.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) throws IOException {
  5.  
  6. int cnt = Integer.parseInt(br.readLine());
  7. int total = 0;
  8. char prev = ' ';
  9. int[] intArr = new int[26];
  10.  
  11. for(int i=0; i<cnt; i++) {
  12. int plus = 0;
  13. char[] charArr = br.readLine().trim().toCharArray();
  14. for(int z=0; z< charArr.length; z++) {
  15. if(intArr[charArr[z]-'a'] == 0) {
  16. prev = charArr[z];
  17. intArr[charArr[z] - 'a'] = 1;
  18. plus = 1;
  19. } else if(intArr[charArr[z]-'a'] != 0 && prev == charArr[z]){
  20. prev = charArr[z];
  21. plus = 1;
  22. } else {
  23. prev = charArr[z];
  24. plus = 0;
  25. }
  26. }
  27. intArr = new int[26];
  28. total += plus;
  29. }
  30. System.out.println(total);
  31. }
  32. }
Success #stdin #stdout 0.08s 47484KB
stdin
1
abac
stdout
1