CSES - DatatÃ¤hti 2022 alku - Results
 Task: Ositus (Partitioning) Sender: Katto Submission time: 2021-10-10 00:34:34 Language: CPython3 Status: READY Result: 0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.02 s1, 2, 3details
#20.02 s1, 2, 3details
#30.02 s1, 2, 3details
#40.02 s1, 2, 3details
#50.02 s2, 3details
#60.02 s3details
#70.23 s3details

### Code

```string = input()
mod = int(1e9+7)
ans = ((1 << (len(string)-1)) - 1) % mod

def finder(string, ch, count):
x = []
cuts = 0
for i in range(count):
x1 = string.find(ch)+cuts
string = string[x1+1:]
cuts += x1 + 1
x.append(x1)

return x

# Periaatteellinen vika looperissa!
# esim merkkijonon "axbxcx" tapauksessa:
# jaettu merkkijono "a|xbxcx" miinustetaan kolmesti yhden kerran sijaan.

def looper(x: str, length, mod):
sum = 0
for i in range(len(x)):
for j in range(len(x)):
if j > i:
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
return sum

for ch in ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "m", "n", "l", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]:
if string.count(ch) > 1:
count = string.count(ch)
if count > 1:
x = finder(string, ch, count)
ans -= looper(x, len(string), mod)

print(ans)
```

### Test details

Group: 1, 2, 3

Verdict:

input
a

correct output
1

user output
0

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
511

#### 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 36, in <module>
ans -= looper(x, len(string), mod)
File "input/code.py", line 27, in looper
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
ValueError: negative shift count```

#### 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 36, in <module>
ans -= looper(x, len(string), mod)
File "input/code.py", line 27, in looper
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
ValueError: negative shift count```

#### 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 36, in <module>
ans -= looper(x, len(string), mod)
File "input/code.py", line 27, in looper
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
ValueError: negative shift count```

#### Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
(empty)

Error:
```Traceback (most recent call last):
File "input/code.py", line 36, in <module>
ans -= looper(x, len(string), mod)
File "input/code.py", line 27, in looper
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
ValueError: negative shift count```

#### Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)

Error:
```Traceback (most recent call last):
File "input/code.py", line 36, in <module>
ans -= looper(x, len(string), mod)
File "input/code.py", line 27, in looper
sum = (sum + (1 << (x[i]-x[j]+length-1)) - 1) % mod
ValueError: negative shift count```