![見出し画像](https://assets.st-note.com/production/uploads/images/157257678/rectangle_large_type_2_09c9451cd36611c8ca7dc3523963aae5.png?width=1200)
文字処理は Data.Text が早い
競プロ典型 90 問 2 日目 - Encyclopedia of Parentheses(★3)
{-# LANGUAGE OverloadedStrings #-}
import Data.Ix
import qualified Data.Text as T
import qualified Data.Text.IO as TI
main = sol <$> readLn >>= mapM_ TI.putStrLn
sol n
| odd n = [""]
| otherwise = go n 0 ""
where
go 0 0 s = [s]
go 0 _ _ = []
go i j s
| (0,n `div` 2) `inRange` j = go (pred i) (succ j) (s<>"(")++go (pred i) (pred j) (s<>")")
| otherwise = []
いいなと思ったら応援しよう!
![karoyakani](https://assets.st-note.com/production/uploads/images/153060341/profile_9698d87ebc4a2db16c1de3967836ae3d.jpg?width=600&crop=1:1,smart)