Last active
February 12, 2018 09:30
-
-
Save deque-blog/fd08997a1ad5366c187e722666606e1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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