CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:Totska
Submission time:2021-10-17 19:06:16 +0300
Language:Python3 (PyPy3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.07 s1, 2, 3details
#20.07 s1, 2, 3details
#30.07 s1, 2, 3details
#40.07 s1, 2, 3details
#50.07 s2, 3details
#60.07 s3details
#70.07 s3details

Code

from collections import deque
from string import ascii_lowercase
from os import read
# import cProfile
#
# pr = cProfile.Profile()
# pr.enable()

# s = "-" + input() + "x"

s = ["-", read(0, 999999999999).decode().strip(), "x"]
def opt_join(x):
    global s
    s = ''.join(x)

opt_join(s)

# print(s)



end = len(s) - 1
maxnb = [end+1 for _ in range(end+1)]
maxnb.append(-1)

minimum = end + 1


seen = {ascii_lowercase[i]: end+1 for i in range(26)}

last = {i: -1 for i in range(end+2)}
distances = deque()

prevdist = 9999999

for 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] = minimum
    seen[s[i]] = i

    last[maxnb[i]] = max(last[maxnb[i]], i)


def getsum(a, b):
    return sumtable[b] - sumtable[a-1]


# i+1 indeksointi
sumtable = [0, 1]


start = 1
mindist = distances.popleft()
for i in range(2, end+1):
    # check
    if i > mindist:
        start = last[mindist] + 1
        mindist = distances.popleft()

    sumtable.append(sumtable[i-1] + getsum(start, i-1))


MOD = 10**9 + 7


print((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:

input
a

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 11, in <module>
    s = ["...