Task: | Ositus |
Sender: | Totska |
Submission time: | 2021-10-17 19:53:49 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 65 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 40 |
#2 | ACCEPTED | 25 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.03 s | 2, 3 | details |
#6 | ACCEPTED | 0.05 s | 3 | details |
#7 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
from collections import dequefrom string import ascii_lowercasefrom os import read# import cProfile## pr = cProfile.Profile()# pr.enable()s = "-" + input() + "x"# s = ["-", read(0, 999999999).decode().strip(), "x"]# s = ["-", input(), "x"]# def opt_join(x):# global s# s = ''.join(x)## opt_join(s)# print(s)end = len(s) - 1maxnb = [end+1 for _ in range(end+1)]maxnb.append(-1)minimum = end + 1seen = {ascii_lowercase[i]: end+1 for i in range(26)}last = {i: -1 for i in range(end+2)}distances = deque()prevdist = 9999999for i in range(end, 0, -1):minimum = min(minimum, seen[s[i]])if minimum < prevdist:distances.insert(0, minimum)prevdist = minimum# maxnb[i] = seen[s[i]]maxnb[i] = minimumseen[s[i]] = ilast[maxnb[i]] = max(last[maxnb[i]], i)def getsum(a, b):return sumtable[b] - sumtable[a-1]# i+1 indeksointisumtable = [0, 1]start = 1mindist = distances.popleft()for i in range(2, end+1):# checkif i > mindist:start = last[mindist] + 1mindist = distances.popleft()sumtable.append(sumtable[i-1] + getsum(start, i-1))MOD = 10**9 + 7print((getsum(end, end)) % MOD)# print(int(getval(end, -1) % MOD))# pr.disable()# pr.print_stats(sort='time')
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
a |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
abcdefghij |
correct output |
---|
512 |
user output |
---|
512 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
abcabaacbc |
correct output |
---|
120 |
user output |
---|
120 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
aaxxxxxxaa |
correct output |
---|
4 |
user output |
---|
4 |
Test 5
Group: 2, 3
Verdict: ACCEPTED
input |
---|
mfyzvoxmppoxcvktmcjkryyocfweub... |
correct output |
---|
643221148 |
user output |
---|
643221148 |
Test 6
Group: 3
Verdict: ACCEPTED
input |
---|
weinscqmmpgbrlboocvtbptgbahmwv... |
correct output |
---|
831644159 |
user output |
---|
831644159 |
Test 7
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
correct output |
---|
816016015 |
user output |
---|
(empty) |