fork download
  1. class Tweet {
  2.  
  3. public static void main(String[] args) throws java.io.IOException {
  4. java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
  5. String[] t = r.readLine().split(" ");
  6.  
  7. int N = Integer.parseInt(t[0]);
  8. int K = Integer.parseInt(t[1]);
  9.  
  10. boolean arr[] = new boolean[N];
  11.  
  12. java.util.Arrays.fill(arr, false);
  13. int count = 0;
  14. for (int i = 0; i < K; i++) {
  15. String t1 = r.readLine();
  16. int n = t1.length();
  17.  
  18. char a = t1.charAt(n - 1);
  19.  
  20. if (a == 'L') {
  21. java.util.Arrays.fill(arr, false);
  22. count = 0;
  23. System.out.println(count);
  24. } else {
  25. int c = Integer.parseInt(t1.substring(n - 1, n));
  26. c = c - 1;
  27. if (arr[c] ) {
  28. arr[c] = false;
  29. count--;
  30. } else {
  31. arr[c] = true;
  32. count++;
  33. }
  34. System.out.println(count);
  35. }
  36.  
  37. }
  38. }
  39. }
Runtime error #stdin #stdout #stderr 0.07s 381184KB
stdin
10 1
CLICK 10
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
	at Tweet.main(Main.java:27)