115482024-10-26 12:14:51balintPeriodikus Szavakpython3Time limit exceeded 41/100587ms3504 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 and (len_sub_text // i) * sub_text[:i] == sub_text:
                print("YES")
                break
        else:
            print("NO")
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted14ms3128 KiB
subtask214/14
2Accepted16ms3128 KiB
3Accepted17ms3076 KiB
4Accepted17ms3128 KiB
5Accepted17ms3068 KiB
6Accepted17ms2940 KiB
7Accepted17ms3128 KiB
8Accepted17ms3092 KiB
9Accepted17ms3128 KiB
10Accepted16ms3092 KiB
11Accepted17ms3132 KiB
12Accepted17ms2996 KiB
subtask327/27
13Accepted48ms3156 KiB
14Accepted48ms3128 KiB
15Accepted50ms3136 KiB
16Accepted18ms3132 KiB
17Accepted41ms3060 KiB
18Accepted48ms3128 KiB
19Accepted50ms3016 KiB
20Accepted28ms2996 KiB
21Accepted48ms3120 KiB
22Accepted54ms3128 KiB
subtask40/59
23Time limit exceeded580ms3128 KiB
24Accepted152ms3128 KiB
25Time limit exceeded582ms3320 KiB
26Time limit exceeded583ms3384 KiB
27Time limit exceeded583ms2984 KiB
28Time limit exceeded583ms2992 KiB
29Time limit exceeded584ms3168 KiB
30Time limit exceeded584ms3128 KiB
31Time limit exceeded584ms3480 KiB
32Time limit exceeded583ms3444 KiB
33Time limit exceeded583ms3128 KiB
34Time limit exceeded583ms3452 KiB
35Time limit exceeded579ms3444 KiB
36Time limit exceeded586ms3480 KiB
37Time limit exceeded586ms3480 KiB
38Time limit exceeded586ms3468 KiB
39Time limit exceeded587ms3504 KiB
40Time limit exceeded578ms3448 KiB
41Time limit exceeded578ms3496 KiB