Submission #581708


Source Code Expand

Copy
import Control.Monad
import Control.Applicative
import Data.List
import System.IO
import qualified Data.IntMap as Map 

main = do
	[k, n] <- (map (read::String -> Int) . words) <$> getLine 
	let temp [m, s] = (map ((subtract (fromEnum '0')).fromEnum) m, s)
	l <- replicateM n (temp .words<$> getLine)
	putStr $ unlines $ Map.elems $ head $ solve l Map.empty

solve::[([Int], String)] -> Map.IntMap String-> [Map.IntMap String]
solve [] res = [res]
solve ((i, goro):ls) res = candidates i goro res >>= solve ls 

candidates::[Int] -> String -> Map.IntMap String -> [Map.IntMap String]
candidates [] [] res = [res]
candidates [] (d:ds) res = []
candidates (i:is) goro res = case Map.lookup i res of
    Just igoro
      |isPrefixOf igoro goro -> candidates is (drop (length igoro) goro) res
      |otherwise -> [] 
    Nothing -> do
    	n <- [1..3]
    	candidates is (drop n goro) (Map.insert i (take n goro) res)

Submission Info

Submission Time
Task D - 語呂合わせ
User dolicas
Language Haskell (Haskell Platform 2014.2.0.0)
Score 100
Code Size 942 Byte
Status AC
Exec Time 41 ms
Memory 2048 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 40 / 40 60 / 60
Status
AC × 4
AC × 23
AC × 44
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Subtask1 sample-02.txt, sample-03.txt, sample-04.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt, subtask1-17.txt, subtask1-18.txt, subtask1-19.txt, subtask1-20.txt
Subtask2 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt, subtask1-17.txt, subtask1-18.txt, subtask1-19.txt, subtask1-20.txt, subtask2-01.txt, subtask2-02.txt, subtask2-03.txt, subtask2-04.txt, subtask2-05.txt, subtask2-06.txt, subtask2-07.txt, subtask2-08.txt, subtask2-09.txt, subtask2-10.txt, subtask2-11.txt, subtask2-12.txt, subtask2-13.txt, subtask2-14.txt, subtask2-15.txt, subtask2-16.txt, subtask2-17.txt, subtask2-18.txt, subtask2-19.txt, subtask2-20.txt
Case Name Status Exec Time Memory
sample-01.txt AC 38 ms 1480 KB
sample-02.txt AC 34 ms 1404 KB
sample-03.txt AC 32 ms 1468 KB
sample-04.txt AC 34 ms 1464 KB
subtask1-01.txt AC 35 ms 1536 KB
subtask1-02.txt AC 35 ms 1528 KB
subtask1-03.txt AC 34 ms 1656 KB
subtask1-04.txt AC 35 ms 1532 KB
subtask1-05.txt AC 33 ms 1660 KB
subtask1-06.txt AC 35 ms 1736 KB
subtask1-07.txt AC 35 ms 1752 KB
subtask1-08.txt AC 35 ms 1652 KB
subtask1-09.txt AC 34 ms 1656 KB
subtask1-10.txt AC 33 ms 1796 KB
subtask1-11.txt AC 35 ms 1996 KB
subtask1-12.txt AC 38 ms 1660 KB
subtask1-13.txt AC 35 ms 1988 KB
subtask1-14.txt AC 34 ms 1588 KB
subtask1-15.txt AC 37 ms 1656 KB
subtask1-16.txt AC 38 ms 2044 KB
subtask1-17.txt AC 35 ms 1660 KB
subtask1-18.txt AC 34 ms 1600 KB
subtask1-19.txt AC 35 ms 1720 KB
subtask1-20.txt AC 35 ms 1796 KB
subtask2-01.txt AC 41 ms 1652 KB
subtask2-02.txt AC 39 ms 1676 KB
subtask2-03.txt AC 34 ms 1716 KB
subtask2-04.txt AC 36 ms 1908 KB
subtask2-05.txt AC 35 ms 1716 KB
subtask2-06.txt AC 33 ms 1788 KB
subtask2-07.txt AC 36 ms 2036 KB
subtask2-08.txt AC 33 ms 1656 KB
subtask2-09.txt AC 33 ms 2012 KB
subtask2-10.txt AC 35 ms 1988 KB
subtask2-11.txt AC 35 ms 1968 KB
subtask2-12.txt AC 34 ms 1744 KB
subtask2-13.txt AC 33 ms 1780 KB
subtask2-14.txt AC 34 ms 1620 KB
subtask2-15.txt AC 34 ms 1744 KB
subtask2-16.txt AC 36 ms 1820 KB
subtask2-17.txt AC 37 ms 1756 KB
subtask2-18.txt AC 37 ms 2044 KB
subtask2-19.txt AC 34 ms 2048 KB
subtask2-20.txt AC 33 ms 2048 KB