結果
| 問題 |
No.1512 作文
|
| コンテスト | |
| ユーザー |
lie_of_lillie
|
| 提出日時 | 2021-06-22 21:23:10 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 714 ms / 2,000 ms |
| コード長 | 486 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 28,160 KB |
| 最終ジャッジ日時 | 2024-06-23 17:27:44 |
| 合計ジャッジ時間 | 7,891 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
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])
lie_of_lillie