結果

問題 No.52 よくある文字列の問題
ユーザー poapoapoapoa
提出日時 2020-09-03 14:09:04
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 11,953 ms
コンパイル使用メモリ 163,792 KB
実行使用メモリ 8,164 KB
最終ジャッジ日時 2023-08-15 10:39:43
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,172 KB
testcase_01 AC 2 ms
7,252 KB
testcase_02 AC 3 ms
7,700 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
7,092 KB
testcase_10 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
import           Data.Set (Set)
import qualified Data.Set as Set

main :: IO ()
main = do
  s <- getLine
  print $ solve (length s) s

solve :: Int -> String -> Int
solve n s = Set.size $ go s "" (Set.singleton s)
  where
    go :: String -> String -> Set String -> Set String
    go t u set
      | t == []   = Set.insert u set
      | otherwise = Set.union (go (tail t) ([head t] ++ u) set) (go (init t) (u ++ [last t]) set)
0