Submission #17502802


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 (w+1)%3==0:
             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][k-1]+dp[k+1][j]+1)
             else:
                 dp[i][j]=max(dp[i])
        else:
            dp[i][j]=max(dp[i])

print(dp[0][-1])

Submission Info

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

Judge Result

Set Name All
Score / Max Score 0 / 5
Status
× 2
× 5
Set Name Test Cases
All 00, 01, 02, 03, 04, 90, 91
Case Name Status Exec Time Memory
00 304 ms 9260 KB
01 240 ms 9400 KB
02 335 ms 9276 KB
03 318 ms 9360 KB
04 253 ms 9304 KB
90 18 ms 9012 KB
91 16 ms 8884 KB