結果

問題 No.1512 作文
ユーザー 👑 KazunKazun
提出日時 2021-05-21 21:37:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 77,928 KB
最終ジャッジ日時 2024-04-18 14:54:12
合計ジャッジ時間 4,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
65,016 KB
testcase_01 AC 53 ms
64,112 KB
testcase_02 AC 54 ms
64,592 KB
testcase_03 AC 53 ms
65,960 KB
testcase_04 AC 154 ms
77,880 KB
testcase_05 AC 158 ms
77,652 KB
testcase_06 AC 158 ms
77,852 KB
testcase_07 AC 161 ms
77,848 KB
testcase_08 AC 157 ms
77,844 KB
testcase_09 AC 55 ms
65,624 KB
testcase_10 AC 54 ms
65,756 KB
testcase_11 AC 55 ms
66,096 KB
testcase_12 AC 60 ms
66,992 KB
testcase_13 AC 57 ms
65,956 KB
testcase_14 AC 97 ms
77,640 KB
testcase_15 AC 100 ms
77,520 KB
testcase_16 AC 98 ms
77,800 KB
testcase_17 AC 99 ms
77,928 KB
testcase_18 AC 97 ms
77,916 KB
testcase_19 AC 100 ms
77,672 KB
testcase_20 AC 98 ms
77,792 KB
testcase_21 AC 56 ms
65,344 KB
testcase_22 AC 55 ms
64,396 KB
testcase_23 AC 55 ms
65,328 KB
testcase_24 AC 57 ms
65,156 KB
testcase_25 AC 56 ms
65,208 KB
testcase_26 AC 53 ms
64,744 KB
testcase_27 AC 51 ms
64,664 KB
testcase_28 AC 54 ms
65,280 KB
testcase_29 AC 53 ms
64,352 KB
testcase_30 AC 54 ms
64,376 KB
testcase_31 AC 54 ms
64,828 KB
testcase_32 AC 55 ms
65,484 KB
testcase_33 AC 56 ms
66,076 KB
testcase_34 AC 57 ms
65,696 KB
testcase_35 AC 58 ms
72,044 KB
testcase_36 AC 59 ms
72,432 KB
testcase_37 AC 56 ms
70,464 KB
testcase_38 AC 58 ms
72,424 KB
testcase_39 AC 60 ms
72,284 KB
testcase_40 AC 191 ms
77,652 KB
testcase_41 AC 175 ms
77,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_good(S):
    p=""
    for s in S:
        if p>s:
            return False
        p=s
    return True

from string import ascii_lowercase as X

N=int(input())
D={a:{b:0 for b  in X} for a in X}

for _ in range(N):
    S=input()
    if not is_good(S): continue

    if S[0]==S[-1]:
        D[S[0]][S[-1]]+=len(S)
    else:
        D[S[0]][S[-1]]=max(D[S[0]][S[-1]],len(S))

X_len=len(X)
DP=[0]*X_len
for i in range(X_len):
    a=X[i]
    DP[i]=D[a][a]
    for j in range(i):
        b=X[j]
        DP[i]=max(DP[i],DP[j]+D[b][a]+D[a][a])

print(max(DP))
0