fork download
  1. import Data.List ( group, sort, transpose )
  2. import GHC.Base (join)
  3. import Control.Arrow ( Arrow((&&&)) )
  4. f a= map $ join.map (\x->[length x:head x] <> replicate (length x - 1) [0]).group.a
  5. f2 x= map (length &&& head).group.map init.sort.filter ((/=0).last).join.f id $ transpose $ f (map (:[])) x
  6. main = readLn >>= print.f2
Runtime error #stdin #stdout #stderr 0s 5620KB
stdin
6 10
0111000011
0000011011
0100011000
0101011011
0100000000
0001111011
stdout
Standard output is empty
stderr
prog: user error (Prelude.readIO: no parse)