Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active February 12, 2018 09:30
Show Gist options
  • Save deque-blog/fd08997a1ad5366c187e722666606e1b to your computer and use it in GitHub Desktop.
Save deque-blog/fd08997a1ad5366c187e722666606e1b to your computer and use it in GitHub Desktop.
import qualified Data.Vector as V
main :: IO ()
main = do
n <- readLn
replicateM_ n $ do
(n, m) <- readMatrix
print (bestQuadrant n m)
type Matrix = V.Vector (V.Vector Int)
readMatrix :: IO (Int, Matrix)
readMatrix = do
n <- readLn
m <- V.replicateM (2 * n) (V.fromList . map read . words getLine)
pure (n, m)
bestQuadrant :: Int -> Matrix -> Int
bestQuadrant n m =
let symetries x = [x, 2 * n - 1 - x]
in sum $ do
i <- [0 .. n-1]
j <- [0 .. n-1]
pure $ maximum $ do
x <- symetries i
y <- symetries j
pure (m V.! x V.! y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment