Loading...
Submission
# When Author Problem Language CPU Memory
20839 2024-06-09 09:28:22 AHAMMED_99 Count Character Python 3 13 ms 8744 kb Wrong Answer - 1
Test Cases
# CPU Memory Points
1 13 ms 8744 kb 0 Wrong Answer
2 0 ms 0 kb 0 Skipped
3 0 ms 0 kb 0 Skipped
4 0 ms 0 kb 0 Skipped
5 0 ms 0 kb 0 Skipped
6 0 ms 0 kb 0 Skipped
7 0 ms 0 kb 0 Skipped
8 0 ms 0 kb 0 Skipped
9 0 ms 0 kb 0 Skipped
Source Code
  1. def count_characters(s):
  2. n = len(s)
  3. alice_count = [0] * (n + 1)
  4. bob_count = [0] * (n + 1)
  5.  
  6. for i in range(1, n + 1):
  7. alice_count[i] = alice_count[i - 1] + (s[i - 1] not in s[:i - 1])
  8. bob_count[i] = bob_count[i - 1] + 1
  9.  
  10. return alice_count, bob_count
  11.  
  12. # Read input
  13. T = int(input())
  14. for case in range(1, T + 1):
  15. N = int(input())
  16. S = input()
  17.  
  18. alice_count, bob_count = count_characters(S)
  19.  
  20. # Compute the total count of Alice and Bob
  21. total_alice_count = sum(alice_count)
  22. total_bob_count = sum(bob_count)
  23.  
  24. # Print the output for this test case
  25. print("Case #{}: {} {}".format(case, total_alice_count, total_bob_count))
  26.