115472024-10-26 12:00:57balintPeriodikus Szavakpython3Time limit exceeded 41/100589ms4092 KiB
from collections import Counter

def main():
    def repeating_good(subtext, fulltext) -> bool:
        return len(fulltext) % len(subtext) == 0 and (len(fulltext) // len(subtext)) * subtext == fulltext

    def periodic(text: str) -> str:
        counter = Counter(text)
            
        chars = "".join(counter.keys())
        
        for i in range(len(chars), len(text)//2+1):
            if repeating_good(text[:i], text):
                return "YES"
        return "NO"

    N = int(input())
    text = input()
    for i in range(int(input())):
        l, r = map(int, input().strip().split())
        print(periodic(text[l:r+1]))

main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted19ms4092 KiB
subtask214/14
2Accepted19ms3384 KiB
3Accepted20ms3540 KiB
4Accepted20ms3384 KiB
5Accepted20ms3616 KiB
6Accepted19ms3392 KiB
7Accepted20ms3384 KiB
8Accepted20ms3544 KiB
9Accepted20ms3448 KiB
10Accepted20ms3380 KiB
11Accepted20ms3488 KiB
12Accepted21ms3380 KiB
subtask327/27
13Accepted152ms3524 KiB
14Accepted142ms3536 KiB
15Accepted144ms3384 KiB
16Accepted26ms3384 KiB
17Accepted118ms3348 KiB
18Accepted141ms3532 KiB
19Accepted150ms3384 KiB
20Accepted68ms3548 KiB
21Accepted142ms3532 KiB
22Accepted167ms3384 KiB
subtask40/59
23Time limit exceeded583ms3568 KiB
24Time limit exceeded528ms3384 KiB
25Time limit exceeded583ms3344 KiB
26Time limit exceeded584ms3596 KiB
27Time limit exceeded580ms3588 KiB
28Time limit exceeded583ms3572 KiB
29Time limit exceeded582ms3476 KiB
30Time limit exceeded583ms3372 KiB
31Time limit exceeded582ms4044 KiB
32Time limit exceeded574ms3896 KiB
33Time limit exceeded574ms3628 KiB
34Time limit exceeded574ms3896 KiB
35Time limit exceeded583ms3912 KiB
36Time limit exceeded583ms3888 KiB
37Time limit exceeded583ms4080 KiB
38Time limit exceeded583ms3896 KiB
39Time limit exceeded582ms3896 KiB
40Time limit exceeded588ms3896 KiB
41Time limit exceeded589ms3896 KiB