CSES - DatatÃ¤hti 2022 alku - Results
 Task: Ositus (Partitioning) Sender: masuman Submission time: 2021-10-10 17:21:27 Language: CPython3 Status: READY Result: 40
Feedback
groupverdictscore
#1ACCEPTED40
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.02 s1, 2, 3details
#2ACCEPTED0.02 s1, 2, 3details
#3ACCEPTED0.02 s1, 2, 3details
#4ACCEPTED0.02 s1, 2, 3details
#5--2, 3details
#6--3details
#7--3details

### Code

```def gS(k):#k is a list of strings that are going to be combined to new strings
s = ""
for i in k:
s += i

result = [""]
g = 0
for i in s:
if i not in result[g]:
result[g] += str(i)
else:
result.append("")
g += 1
result[g] += str(i)
return result

def bS(k): #only when situation like kabba occurs, kab ba --> ka b ba --> k ab ba -bS-> k a b ba --> k a b b a
return [k[:-1], k[-1]] #returns a list

def dS(s,t): #transfers the last char of left string to right
return [s[:-1], s[-1]+t]
def case1(lista, iS):
x = dS(lista[-(iS+1)], lista[-iS])
lista[-(iS+1)] = x[0]
lista[-iS] = x[1]
return lista
def case2(lista, iS):
x = [lista[-(iS+1)][-1]]
x += lista[-(iS):]
x = gS(x)
del lista[-(iS):]
lista[-1] = lista[-1][:-1] #removing the last character
lista += x
return lista
def case3(lista, iS):
#we go back the elements in lista until we find an element that is NOT singular
d = 1 #the amount of steps we need to go back until we find an element that is not singular
while len(lista[-(iS+d)]) == 1:
d += 1
x = [lista[-(iS+d)][-1]]
x += lista[-(iS+d-1):]
x = gS(x)
del lista[-(iS+d-1):]
#print(lista, iS, d)
lista[-1] = lista[-1][:-1]
lista += x
return lista
def case4(lista, iS):
print("kakka")
def getIs(lista):
for iS in range(1,len(lista)+1):
if iS == len(lista):
return iS
if lista[-(iS+1)][-1] != lista[-iS][0]:
return iS
def tails(lista, iS):
pii = 1
for i in range(1, iS+1):
pii *= pow(2, len(lista[-(i)])-1)
return pii
def calc(s):
lista = gS(s)
#print(lista)
if len(lista[0]) == 1: #remove all the elements from the left that are singular, important for poss. 3
while len(lista[0]) == 1:
lista.pop(0)
if len(lista) == 0:
return 1
if len(lista) == 1:
return pow(2, len(lista[0])-1)
summa = pow(2, len(lista[-1])-1)
iS = 1 #how many "tails" do we have, e.g. ka k ka --> 2 tails "k" and "ka", we only manipulate the left-most tail, thats why we keep count of
while len(lista) > iS: #DOES NOT TAKE INTO CONSIDERATION WHETHER THE LIST IS ACTUALLY JUST 1 CHAR LONG!!! HAS TO BE DONE IN A RATHER DIRTY WAY

#print(lista)
#possibility 1: we can expand the last element of the list, i.e. the second last element's last element is not in the last element AND the second last element is not singular
if lista[-(iS+1)][-1] not in lista[-iS] and len(lista[-(iS+1)]) != 1:
lista = case1(lista, iS)
#print("case1:", lista)

#possibility 2: we cannot expand the last element of the list, i.e. the second last element's last element is in the last element AND the second last element is not singular
elif lista[-(iS+1)][-1] in lista[-iS] and len(lista[-(iS+1)]) != 1:
lista = case2(lista, iS)
#print("case2:", lista)
#possibility 3: we cannot expand the last element of the list, i.e. the second last element's last element is in the last element AND the second last element IS singular
elif len(lista[-(iS+1)]) == 1:
lista = case3(lista, iS)
#print("case3:", lista)
if len(lista[0]) == 1: #remove all the elements from the left that are singular, important for poss. 3
while len(lista[0]) == 1:
lista.pop(0)

iS = getIs(lista)
summa += tails(lista, iS)
#print(lista, iS)
return summa
x = str(input())

print(calc(x))
```

### 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:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
(empty)

#### Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
(empty)

#### Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)