115492024-10-26 12:45:37balintPeriodikus Szavakpython3Time limit exceeded 41/100592ms3568 KiB
def main():
    input()
    text = input()
    for _ in range(int(input())):
        l, r = map(int, input().strip().split())
        sub_text = text[l:r+1]
        chars_len = len(set(sub_text))
        len_sub_text = r+1-l
        for i in range(chars_len, len_sub_text//2+1):
            if len_sub_text % i == 0:
                repeated_part = sub_text[:i]
                if repeated_part * (len_sub_text // i) == sub_text:
                    print("YES")
                    break
        else:
            print("NO")
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted14ms3128 KiB
subtask214/14
2Accepted16ms3148 KiB
3Accepted17ms3128 KiB
4Accepted16ms3028 KiB
5Accepted17ms3128 KiB
6Accepted16ms3084 KiB
7Accepted17ms3128 KiB
8Accepted16ms3060 KiB
9Accepted17ms3084 KiB
10Accepted17ms3136 KiB
11Accepted17ms3144 KiB
12Accepted17ms3132 KiB
subtask327/27
13Accepted50ms3144 KiB
14Accepted46ms3144 KiB
15Accepted48ms3128 KiB
16Accepted18ms3124 KiB
17Accepted43ms3128 KiB
18Accepted46ms3128 KiB
19Accepted46ms3084 KiB
20Accepted28ms3024 KiB
21Accepted48ms3320 KiB
22Accepted54ms3072 KiB
subtask40/59
23Time limit exceeded583ms3128 KiB
24Accepted149ms3316 KiB
25Time limit exceeded583ms3140 KiB
26Time limit exceeded583ms3184 KiB
27Time limit exceeded583ms3128 KiB
28Time limit exceeded582ms3128 KiB
29Time limit exceeded582ms3128 KiB
30Time limit exceeded582ms3156 KiB
31Time limit exceeded589ms3552 KiB
32Time limit exceeded583ms3544 KiB
33Time limit exceeded584ms3132 KiB
34Time limit exceeded584ms3476 KiB
35Time limit exceeded579ms3552 KiB
36Time limit exceeded580ms3568 KiB
37Time limit exceeded582ms3488 KiB
38Time limit exceeded582ms3516 KiB
39Time limit exceeded578ms3520 KiB
40Time limit exceeded591ms3536 KiB
41Time limit exceeded592ms3520 KiB