結果

問題 No.1512 作文
ユーザー lie_of_lillielie_of_lillie
提出日時 2021-06-22 21:23:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 568 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 25,980 KB
最終ジャッジ日時 2023-09-05 22:07:45
合計ジャッジ時間 6,935 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,500 KB
testcase_01 AC 19 ms
8,584 KB
testcase_02 AC 19 ms
8,588 KB
testcase_03 AC 19 ms
8,588 KB
testcase_04 AC 386 ms
20,044 KB
testcase_05 AC 384 ms
20,180 KB
testcase_06 AC 378 ms
20,032 KB
testcase_07 AC 380 ms
20,032 KB
testcase_08 AC 381 ms
20,188 KB
testcase_09 AC 50 ms
10,216 KB
testcase_10 AC 51 ms
10,200 KB
testcase_11 AC 51 ms
10,352 KB
testcase_12 AC 52 ms
10,232 KB
testcase_13 AC 52 ms
10,448 KB
testcase_14 AC 79 ms
11,404 KB
testcase_15 AC 79 ms
11,464 KB
testcase_16 AC 80 ms
11,488 KB
testcase_17 AC 79 ms
11,236 KB
testcase_18 AC 80 ms
11,240 KB
testcase_19 AC 79 ms
11,328 KB
testcase_20 AC 79 ms
11,260 KB
testcase_21 AC 20 ms
8,616 KB
testcase_22 AC 20 ms
8,732 KB
testcase_23 AC 21 ms
8,632 KB
testcase_24 AC 21 ms
8,784 KB
testcase_25 AC 22 ms
8,672 KB
testcase_26 AC 20 ms
8,508 KB
testcase_27 AC 19 ms
8,656 KB
testcase_28 AC 19 ms
8,504 KB
testcase_29 AC 19 ms
8,484 KB
testcase_30 AC 19 ms
8,588 KB
testcase_31 AC 19 ms
8,672 KB
testcase_32 AC 19 ms
8,684 KB
testcase_33 AC 19 ms
8,596 KB
testcase_34 AC 20 ms
8,652 KB
testcase_35 AC 29 ms
11,484 KB
testcase_36 AC 28 ms
11,556 KB
testcase_37 AC 24 ms
10,704 KB
testcase_38 AC 27 ms
10,124 KB
testcase_39 AC 27 ms
10,252 KB
testcase_40 AC 567 ms
25,980 KB
testcase_41 AC 568 ms
25,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

N = int(input())
S = [list(input()) for _ in range(N)]

tmp = collections.defaultdict(int)
for s in S:
    if not s == sorted(s):
        continue
    key = (s[0], s[-1])
    size = len(s)
    if s[0] == s[-1]:
        tmp[key] += size
    else:
        tmp[key] = max(tmp[key], size)


dp = [0] * 26
for a in range(26):
    for b in range(a):
        dp[a] = max(dp[a], dp[b] + tmp[(chr(b + 97), chr(a + 97))])
    dp[a] += tmp[(chr(a+97), chr(a+97))]
print(dp[-1])
0