Submission #51308337


Source Code Expand

S = input()
D = dict()
ls = len(S)
ans = ls * (ls - 1) / 2
f = True

for i in range(ls):
    s = S[i]
    if s in D:
        D[s] += 1
    else:
        D[s] = 1

for key in D:
    d = D[key]
    m = d * (d - 1) / 2
    ans -= m
    if not m == 0 and f:
        ans += 1
        f = False
        
print(int(ans))

Submission Info

Submission Time
Task C - One Time Swap
User zenmaaa
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 334 Byte
Status AC
Exec Time 103 ms
Memory 84124 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 2
AC × 24
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
Case Name Status Exec Time Memory
example_00.txt AC 56 ms 76616 KiB
example_01.txt AC 56 ms 76688 KiB
hand_00.txt AC 81 ms 82708 KiB
hand_01.txt AC 55 ms 76468 KiB
hand_02.txt AC 55 ms 76496 KiB
hand_03.txt AC 56 ms 76444 KiB
hand_04.txt AC 54 ms 76364 KiB
hand_05.txt AC 99 ms 84048 KiB
hand_06.txt AC 98 ms 83796 KiB
random_00.txt AC 55 ms 76204 KiB
random_01.txt AC 56 ms 76460 KiB
random_02.txt AC 55 ms 76316 KiB
random_03.txt AC 55 ms 76468 KiB
random_04.txt AC 56 ms 76540 KiB
random_05.txt AC 103 ms 84044 KiB
random_06.txt AC 101 ms 83728 KiB
random_07.txt AC 101 ms 83520 KiB
random_08.txt AC 102 ms 83432 KiB
random_09.txt AC 103 ms 83792 KiB
random_10.txt AC 101 ms 84000 KiB
random_11.txt AC 99 ms 83496 KiB
random_12.txt AC 100 ms 83252 KiB
random_13.txt AC 101 ms 83876 KiB
random_14.txt AC 103 ms 84124 KiB