結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2015-09-01 22:25:58 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 6,784 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-06-25 13:27:57 |
合計ジャッジ時間 | 1,565 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
S = raw_input()pail = [[False for j in range(51)] for i in range(51)]N = len(S)ans = 0def solve(pos, res):global ansif (pos == N):ans = max(ans, res)returnfor i in range(pos, N):if (pail[pos][i]):next = max(res, (i - pos) + 1)solve(i + 1, next)for i in range(N):left = iright = iwhile (left >= 0 and right < N):if (S[left] == S[right]):pail[left][right] = Trueelse:breakleft -= 1right += 1left = iright = i + 1while (left >= 0 and right < N):if (S[left] == S[right]):pail[left][right] = Trueelse:breakleft -= 1right += 1for i in range(N):for j in range(i, N):if (pail[i][j] and not(i == 0 and j == N - 1)):ans = max(ans, j - i + 1)print ans