結果

問題 No.1512 作文
ユーザー 👑 KazunKazun
提出日時 2021-05-21 21:35:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 78,312 KB
最終ジャッジ日時 2024-04-18 14:53:00
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
64,204 KB
testcase_01 AC 58 ms
64,496 KB
testcase_02 AC 60 ms
64,024 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 58 ms
66,104 KB
testcase_10 AC 58 ms
66,168 KB
testcase_11 AC 64 ms
65,964 KB
testcase_12 AC 62 ms
66,796 KB
testcase_13 AC 60 ms
66,040 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 61 ms
65,772 KB
testcase_22 AC 58 ms
64,344 KB
testcase_23 AC 60 ms
66,368 KB
testcase_24 AC 59 ms
65,144 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 60 ms
64,112 KB
testcase_28 AC 62 ms
65,272 KB
testcase_29 AC 59 ms
64,192 KB
testcase_30 AC 58 ms
65,072 KB
testcase_31 AC 61 ms
65,384 KB
testcase_32 AC 60 ms
65,284 KB
testcase_33 AC 59 ms
65,352 KB
testcase_34 AC 60 ms
66,312 KB
testcase_35 WA -
testcase_36 AC 62 ms
72,168 KB
testcase_37 AC 61 ms
69,128 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 183 ms
77,524 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]
    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