Submission #74094367


Source Code Expand

import bisect

n, l, r = map(int, input().split())
s = input().strip()

pos = [[] for _ in range(26)]
for i, char in enumerate(s):
    pos[ord(char) - ord("a")].append(i)

ans = 0
for i in range(n):
    temp = ord(s[i]) - ord("a")
    right = i + r
    left = i + l
    
    cnt = bisect.bisect_right(pos[temp], right) - bisect.bisect_left(pos[temp], left)
    ans += cnt

print(ans)

Submission Info

Submission Time
Task C - Comfortable Distance
User gett
Language Python (PyPy 3.11-v7.3.20)
Score 300
Code Size 401 Byte
Status AC
Exec Time 316 ms
Memory 146432 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 23
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt
Case Name Status Exec Time Memory
sample00.txt AC 57 ms 80308 KiB
sample01.txt AC 56 ms 80252 KiB
sample02.txt AC 57 ms 80532 KiB
testcase00.txt AC 57 ms 80144 KiB
testcase01.txt AC 56 ms 80144 KiB
testcase02.txt AC 100 ms 109304 KiB
testcase03.txt AC 150 ms 117592 KiB
testcase04.txt AC 145 ms 111332 KiB
testcase05.txt AC 137 ms 112028 KiB
testcase06.txt AC 130 ms 110064 KiB
testcase07.txt AC 229 ms 117824 KiB
testcase08.txt AC 242 ms 117916 KiB
testcase09.txt AC 234 ms 117688 KiB
testcase10.txt AC 270 ms 117636 KiB
testcase11.txt AC 226 ms 118120 KiB
testcase12.txt AC 293 ms 146432 KiB
testcase13.txt AC 230 ms 146412 KiB
testcase14.txt AC 151 ms 146420 KiB
testcase15.txt AC 316 ms 145936 KiB
testcase16.txt AC 295 ms 130076 KiB
testcase17.txt AC 240 ms 130428 KiB
testcase18.txt AC 152 ms 130160 KiB
testcase19.txt AC 250 ms 130792 KiB