| Task: | Ositus |
| Sender: | Kirill_Akimov |
| Submission time: | 2021-10-14 17:25:42 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #4 | WRONG ANSWER | 0.04 s | 1, 2, 3 | details |
| #5 | WRONG ANSWER | 0.04 s | 2, 3 | details |
| #6 | WRONG ANSWER | 0.06 s | 3 | details |
| #7 | WRONG ANSWER | 0.26 s | 3 | details |
Code
string = input()
length = len(string)
symbol = ['', string[0]]
index_of_l = [0, 1]
index_of_ntl = [0, 0]
number_for_l = [0, 1]
number_for_ntl = [0, 0]
count = 2
rightest_ntl = 0
preceding = 1
prime_modulus = 1000000007
for i in range(1, length):
if string[i-1] == string[i]:
index_of_ntl[preceding] = index_of_l[preceding]
index_of_l[preceding] = i
number_for_ntl[preceding] = number_for_l[preceding]
continue
for j in range(1, count):
if string[i] == symbol[j]:
if index_of_ntl[rightest_ntl] > index_of_l[j]:
index_of_ntl[j] = index_of_l[j]
index_of_l[j] = i
number_for_ntl[j] = number_for_l[j]
number_for_l[j] = 2 * number_for_l[preceding]
elif index_of_l[rightest_ntl] <= index_of_l[j]:
index_of_ntl[j] = index_of_l[j]
index_of_l[j] = i
number_for_ntl[j] = number_for_l[j]
number_for_l[j] = 2 * number_for_l[preceding] - number_for_ntl[j]
rightest_ntl = j
else:
index_of_ntl[j] = index_of_l[j]
index_of_l[j] = i
number_for_ntl[j] = number_for_l[j]
number_for_l[j] = 2 * number_for_l[preceding] - number_for_ntl[j] + number_for_ntl[rightest_ntl]
number_for_ntl[j] -= number_for_ntl[rightest_ntl]
rightest_ntl = j
if not 0 <= number_for_l[j] < prime_modulus:
number_for_l[j] %= prime_modulus
preceding = j
break
else:
symbol += [string[i]]
index_of_l += [i]
index_of_ntl += [0]
number_for_l += [2 * number_for_l[preceding]]
count += 1
if number_for_l[count - 1] > prime_modulus:
number_for_l[count - 1] %= prime_modulus
number_for_ntl += [0]
preceding = count - 1
print(number_for_l[preceding])
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: WRONG ANSWER
| input |
|---|
| aaxxxxxxaa |
| correct output |
|---|
| 4 |
| user output |
|---|
| 3 |
Test 5
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| mfyzvoxmppoxcvktmcjkryyocfweub... |
| correct output |
|---|
| 643221148 |
| user output |
|---|
| 465352316 |
Test 6
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| weinscqmmpgbrlboocvtbptgbahmwv... |
| correct output |
|---|
| 831644159 |
| user output |
|---|
| 153239858 |
Test 7
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
| correct output |
|---|
| 816016015 |
| user output |
|---|
| 374095164 |
