1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import Data.List import Data.Function readArray [] _ acc = concat acc readArray (line:rest) n acc = readArray rest (n+1) ((readLine n line):acc) where readLine y line = map (\(x, s) -> ((x, y), read s::Int)) $ zip [0..] $ words line filterArray acc [] = reverse acc filterArray acc (val@((x,y), _):rest) = filterArray (val:acc) $ filter ((/=x).fst.fst) $ filter ((/=y).snd.fst) $ rest main = do content <- getContents print $ filterArray [] $ reverse $ sortBy (compare `on` snd) $ readArray (lines content) 0 [] |
-
upload with new input
-
result: Success time: 0.02s memory: 3724 kB returned value: 0
1 0 1 0 -1 0 -1 0 0 2 2 0 0 0 0 0
[((2,2),2),((0,0),1),((3,1),0),((1,3),0)]
-
result: Success time: 0.01s memory: 3724 kB returned value: 0
1 0 -1 0 0 0 -1 1 -1 0 1 -1
[((0,0),1),((3,1),1),((2,2),1)]
-
result: Success time: 0.02s memory: 3724 kB returned value: 0
-68 -84 -90 -70 -99 -98 -85 -61 -61 -55 -83 -54 -66 -85 -92 -92 -93 -80 -92 -75 -69 -59 -75 -86 -53
[((4,4),-53),((1,2),-54),((3,1),-61),((0,0),-68),((2,3),-80)]
-
result: Success time: 0.02s memory: 3724 kB returned value: 0
1 2 3 4 5 6 7 8 9
[((2,2),9),((1,1),5),((0,0),1)]
-
result: Success time: 0.02s memory: 3724 kB returned value: 0
60 20 30 50 41 50 40 66 78 83 37 77 59 12 100 88
[((2,3),100),((1,2),83),((3,1),66),((0,0),60)]



