Submission #3787783


Source Code Expand

import Control.Monad
import Text.Printf

height :: Int -> Int -> [[Int]] -> Int
height cx cy ps = if (all (\[x, y, h] -> h == (max 0 (ch - (abs (cx - x)) - (abs (cy - y))))) ps) then ch else 0
  where
    [x0, y0, h0]:_ = filter (\[x, y, h] -> h > 0) ps
    ch = h0 + (abs (cx - x0)) + (abs (cy - y0))

solve :: [[Int]] -> (Int, Int, Int)
solve ps = t
  where
    t:_ = filter (\(x, y, h) -> h > 0) [(cx, cy, height cx cy ps) | cx <- [0 .. 100], cy <- [0 .. 100]]


main :: IO ()
main = do
  n <- readLn :: IO Int
  ps <- replicateM n $ (map (\s -> read s :: Int)) . words <$> getLine
  let (cx, cy, ch) = solve ps in
    printf "%d %d %d\n" cx cy ch

Submission Info

Submission Time
Task C - Pyramid
User hi_watana
Language Haskell (GHC 7.10.3)
Score 300
Code Size 672 Byte
Status AC
Exec Time 4 ms
Memory 1020 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 23
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
in01.txt AC 2 ms 508 KB
in02.txt AC 2 ms 1020 KB
in03.txt AC 2 ms 1020 KB
in04.txt AC 2 ms 892 KB
in05.txt AC 2 ms 764 KB
in06.txt AC 2 ms 1020 KB
in07.txt AC 2 ms 1020 KB
in08.txt AC 2 ms 636 KB
in09.txt AC 2 ms 764 KB
in10.txt AC 2 ms 1020 KB
in11.txt AC 3 ms 1020 KB
in12.txt AC 3 ms 1020 KB
in13.txt AC 3 ms 1020 KB
in14.txt AC 3 ms 1020 KB
in15.txt AC 4 ms 1020 KB
in16.txt AC 3 ms 1020 KB
in17.txt AC 3 ms 1020 KB
in18.txt AC 4 ms 1020 KB
in19.txt AC 4 ms 1020 KB
in20.txt AC 3 ms 1020 KB
s1.txt AC 2 ms 508 KB
s2.txt AC 2 ms 508 KB
s3.txt AC 2 ms 1020 KB