Submission #17508161


Source Code Expand

Copy
S=str(input())
 
dp = [[0]*(len(S)) for _ in range(len(S))]
 
for w in range(2,len(S)+1):
    for i in range(len(S)):
        j=w+i
        if j>=len(S):
            continue
        if S[i:j+1]=="iwi":
            dp[i][j]=1
            continue
        
        if S[i]=="i" and S[j]=="i":
                for k in range(i+1,j-1):
                    if S[k]=="w":
                        dp[i][j]=max(dp[i][j],dp[i+1][k]+dp[k+1][j-1]+1)
            
        for mid in range(i+1,j):
            dp[i][j]=max(dp[i][j],dp[i][mid]+dp[mid+1][j])
    
print(dp[0][-1])

Submission Info

Submission Time
Task I - イウィ
User Matsuda123
Language Python (3.8.2)
Score 0
Code Size 587 Byte
Status
Exec Time 2206 ms
Memory 9580 KB

Judge Result

Set Name All
Score / Max Score 0 / 5
Status
× 2
× 2
× 3
Set Name Test Cases
All 00, 01, 02, 03, 04, 90, 91
Case Name Status Exec Time Memory
00 2131 ms 9344 KB
01 1923 ms 9236 KB
02 2206 ms 9580 KB
03 2205 ms 9348 KB
04 1746 ms 9220 KB
90 20 ms 8988 KB
91 24 ms 9184 KB