11547 | 2024-10-26 12:00:57 | balint | Periodikus Szavak | python3 | Time limit exceeded 41/100 | 589ms | 4092 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()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 19ms | 4092 KiB | ||||
subtask2 | 14/14 | ||||||
2 | Accepted | 19ms | 3384 KiB | ||||
3 | Accepted | 20ms | 3540 KiB | ||||
4 | Accepted | 20ms | 3384 KiB | ||||
5 | Accepted | 20ms | 3616 KiB | ||||
6 | Accepted | 19ms | 3392 KiB | ||||
7 | Accepted | 20ms | 3384 KiB | ||||
8 | Accepted | 20ms | 3544 KiB | ||||
9 | Accepted | 20ms | 3448 KiB | ||||
10 | Accepted | 20ms | 3380 KiB | ||||
11 | Accepted | 20ms | 3488 KiB | ||||
12 | Accepted | 21ms | 3380 KiB | ||||
subtask3 | 27/27 | ||||||
13 | Accepted | 152ms | 3524 KiB | ||||
14 | Accepted | 142ms | 3536 KiB | ||||
15 | Accepted | 144ms | 3384 KiB | ||||
16 | Accepted | 26ms | 3384 KiB | ||||
17 | Accepted | 118ms | 3348 KiB | ||||
18 | Accepted | 141ms | 3532 KiB | ||||
19 | Accepted | 150ms | 3384 KiB | ||||
20 | Accepted | 68ms | 3548 KiB | ||||
21 | Accepted | 142ms | 3532 KiB | ||||
22 | Accepted | 167ms | 3384 KiB | ||||
subtask4 | 0/59 | ||||||
23 | Time limit exceeded | 583ms | 3568 KiB | ||||
24 | Time limit exceeded | 528ms | 3384 KiB | ||||
25 | Time limit exceeded | 583ms | 3344 KiB | ||||
26 | Time limit exceeded | 584ms | 3596 KiB | ||||
27 | Time limit exceeded | 580ms | 3588 KiB | ||||
28 | Time limit exceeded | 583ms | 3572 KiB | ||||
29 | Time limit exceeded | 582ms | 3476 KiB | ||||
30 | Time limit exceeded | 583ms | 3372 KiB | ||||
31 | Time limit exceeded | 582ms | 4044 KiB | ||||
32 | Time limit exceeded | 574ms | 3896 KiB | ||||
33 | Time limit exceeded | 574ms | 3628 KiB | ||||
34 | Time limit exceeded | 574ms | 3896 KiB | ||||
35 | Time limit exceeded | 583ms | 3912 KiB | ||||
36 | Time limit exceeded | 583ms | 3888 KiB | ||||
37 | Time limit exceeded | 583ms | 4080 KiB | ||||
38 | Time limit exceeded | 583ms | 3896 KiB | ||||
39 | Time limit exceeded | 582ms | 3896 KiB | ||||
40 | Time limit exceeded | 588ms | 3896 KiB | ||||
41 | Time limit exceeded | 589ms | 3896 KiB |