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 |
Source Code
def count_characters(s): n = len(s) alice_count = [0] * (n + 1) bob_count = [0] * (n + 1) for i in range(1, n + 1): alice_count[i] = alice_count[i - 1] + (s[i - 1] not in s[:i - 1]) bob_count[i] = bob_count[i - 1] + 1 return alice_count, bob_count # Read input T = int(input()) for case in range(1, T + 1): N = int(input()) S = input() alice_count, bob_count = count_characters(S) # Compute the total count of Alice and Bob total_alice_count = sum(alice_count) total_bob_count = sum(bob_count) # Print the output for this test case print("Case #{}: {} {}".format(case, total_alice_count, total_bob_count))