Notice
Recent Posts
Recent Comments
Graphics Programming
[ALGOSPOT] URI - 단순 텍스트 복호화 본문
문제: https://algospot.com/judge/problem/read/URI
쉬운 거 그만 풀려고 했는데 이 문제는 댓글에 하도 함정이 있느니 어쩌느니 해서 한 번 풀어봤다.
한 방에 통과되는데.. 뭐가 함정이라는 거지 -_-
쉬운 거 그만 풀려고 했는데 이 문제는 댓글에 하도 함정이 있느니 어쩌느니 해서 한 번 풀어봤다.
main = do
num_s <- getLine
let num = read num_s :: Int
forM_ [1..num] $ const $ do
encoded <- getLine
putStrLn $ decode encoded
decode :: String -> String
decode [] = []
decode (x:xs) = case x of
'%' -> special xs
_ -> x : decode xs
where special (z:y:ys) = case y of
'0' -> ' ' : decode ys
'1' -> '!' : decode ys
'4' -> '$' : decode ys
'5' -> '%' : decode ys
'8' -> '(' : decode ys
'9' -> ')' : decode ys
'a' -> '*' : decode ys
_ -> '%' : z : y : decode ys
한 방에 통과되는데.. 뭐가 함정이라는 거지 -_-
Comments