結果

問題 No.464 PPAP
ユーザー Hirotaka OhkuboHirotaka Ohkubo
提出日時 2017-03-03 00:09:04
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 570 bytes
コンパイル時間 7,448 ms
コンパイル使用メモリ 161,616 KB
実行使用メモリ 14,580 KB
最終ジャッジ日時 2023-09-03 21:17:45
合計ジャッジ時間 14,620 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,508 KB
testcase_01 AC 3 ms
6,688 KB
testcase_02 AC 3 ms
6,768 KB
testcase_03 AC 3 ms
6,584 KB
testcase_04 AC 6 ms
7,316 KB
testcase_05 AC 4 ms
6,772 KB
testcase_06 AC 3 ms
6,688 KB
testcase_07 TLE -
testcase_08 AC 412 ms
10,820 KB
testcase_09 AC 3 ms
7,092 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List (isPrefixOf)

palis (x:xs) = 1 : inner 1 [x] xs where
  inner _ _  [] = []
  inner n rs (x:xs) =
    (if isPrefixOf rs (x:xs) then (n*2   :) else id) $
    (if isPrefixOf rs xs     then (n*2+1 :) else id) $ inner (n+1) (x:rs) xs

compute src = length ans where
  len = length src
  l1s = palis $ take (len-3) src
  l1l2s = [ l1 + l2 | l1 <- l1s, let rest = drop l1 (take (len-2) src), l2 <- palis rest ]
  l3s = palis $ reverse $ drop 3 src
  ans = [ () | l1l2 <- l1l2s, l3 <- takeWhile (len - l1l2 >) l3s]

main = do
  l <- getLine
  print $ compute l
0