Submission #171583


Source Code Expand

Copy
{-# LANGUAGE CPP #-}
#ifndef HDEVTOOLS
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
#endif
{-# LANGUAGE BangPatterns, ViewPatterns, OverloadedStrings #-}

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as S
import qualified Data.Vector.Unboxed as U
import Data.Bits

main :: IO ()
main = do
  [r, c, d] <- map readInt . S.words <$> S.getLine
  m <- fmap U.concat $ replicateM r $ do
    U.fromList . map readInt . S.words <$> S.getLine
  print $ solve c d m

solve :: Int -> Int -> U.Vector Int -> Int
solve width !d m = U.maximum $ U.ifilter good m
  where
    !parity = d .&. 1
    good i _ = abs x + abs y <= d && (x + y) .&. 1 == parity
      where
        !(y, x) = divMod i width

readInt :: S.ByteString -> Int
readInt s = case S.readInt s of
  Just (r, "") -> r
  _ -> error $ "not an integer: " ++ show s

Submission Info

Submission Time
Task B - 謎の人物X
User mkotha
Language Haskell (GHC 7.4.1)
Score 100
Code Size 886 Byte
Status AC
Exec Time 602 ms
Memory 9000 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 60 / 60 40 / 40
Status
AC × 3
AC × 18
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 532 ms 1316 KB
sample_02.txt AC 348 ms 1308 KB
sample_03.txt AC 289 ms 1316 KB
subtask1_01.txt AC 31 ms 1320 KB
subtask1_02.txt AC 32 ms 1440 KB
subtask1_03.txt AC 30 ms 1568 KB
subtask1_04.txt AC 47 ms 1952 KB
subtask1_05.txt AC 30 ms 1576 KB
subtask1_06.txt AC 30 ms 1836 KB
subtask1_07.txt AC 33 ms 1960 KB
subtask1_08.txt AC 34 ms 2068 KB
subtask1_09.txt AC 31 ms 2080 KB
subtask1_10.txt AC 31 ms 2080 KB
subtask1_11.txt AC 33 ms 1964 KB
subtask1_12.txt AC 32 ms 2076 KB
subtask1_13.txt AC 32 ms 2076 KB
subtask1_14.txt AC 34 ms 2088 KB
subtask1_15.txt AC 32 ms 2080 KB
subtask2_01.txt AC 29 ms 1820 KB
subtask2_02.txt AC 33 ms 2084 KB
subtask2_03.txt AC 110 ms 5156 KB
subtask2_04.txt AC 31 ms 1944 KB
subtask2_05.txt AC 42 ms 2472 KB
subtask2_06.txt AC 67 ms 3740 KB
subtask2_07.txt AC 217 ms 6440 KB
subtask2_08.txt AC 302 ms 8360 KB
subtask2_09.txt AC 300 ms 8480 KB
subtask2_10.txt AC 427 ms 8472 KB
subtask2_11.txt AC 414 ms 9000 KB
subtask2_12.txt AC 602 ms 8348 KB
subtask2_13.txt AC 392 ms 8352 KB
subtask2_14.txt AC 486 ms 8460 KB
subtask2_15.txt AC 439 ms 8484 KB