Submission #43171167


Source Code Expand

Copy
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Array
main = do
[n] <- bsGetLnInts
as <- bsGetLnInts
s <- BS.getLine
let ans = abc308e n as s
print ans
bsGetLnInts :: IO [Int]
bsGetLnInts = BS.getLine >>= return . unfoldr (BS.readInt . BS.dropWhile isSpace)
abc308e :: Int -> [Int] -> BS.ByteString -> Int
abc308e n as s = sum ps
where
(_,ps) = mapAccumL step ([0,0,0],x012) $ zip as $ BS.unpack s
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

import Data.Array

main = do
  [n] <- bsGetLnInts
  as <- bsGetLnInts
  s <- BS.getLine
  let ans = abc308e n as s
  print ans

bsGetLnInts :: IO [Int]
bsGetLnInts = BS.getLine >>= return . unfoldr (BS.readInt . BS.dropWhile isSpace)

abc308e :: Int -> [Int] -> BS.ByteString -> Int
abc308e n as s = sum ps
  where
    (_,ps) = mapAccumL step ([0,0,0],x012) $ zip as $ BS.unpack s
    x012 = elems $ accumArray (+) 0 (0,2)
           [(ai, 1) | (ai, 'X') <- zip as $ BS.unpack s]
    step (m012,x012) (ai,'M') = ((triple ai succ m012, x012), 0)
    step (m012,x012) (ak,'X') = ((m012, triple ak pred x012), 0)
    step tt@(m012,x012) (aj,'E') = (tt, p)
      where
        p = sum [ ci * ck * pa ! (ai,aj,ak)
                | (ci,ai) <- zip m012 [0..]
                , (ck,ak) <- zip x012 [0..]
                ]

-- point array
pa = listArray ((0,0,0),(2,2,2))
     [head $ [x | x <- [0..2], x /= ai, x /= aj, x /= ak] ++ [3]
     | ai <- [0..2], aj <- [0..2], ak <- [0..2]]

triple 0 f [a,b,c] = [f a, b, c]
triple 1 f [a,b,c] = [a, f b, c]
triple 2 f [a,b,c] = [a, b, f c]

Submission Info

Submission Time
Task E - MEX
User joetheshootingst
Language Haskell (GHC 8.8.3)
Score 475
Code Size 1219 Byte
Status AC
Exec Time 128 ms
Memory 47440 KB

Compile Error

Loaded package environment from /home/contestant/.ghc/x86_64-linux-8.8.3/environments/default

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 03_zero_00.txt, 03_zero_01.txt, 03_zero_02.txt, 04_handmade_00.txt, 04_handmade_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 7 ms 3556 KB
00_sample_01.txt AC 2 ms 3548 KB
00_sample_02.txt AC 2 ms 3520 KB
01_random_00.txt AC 72 ms 16496 KB
01_random_01.txt AC 74 ms 16124 KB
01_random_02.txt AC 79 ms 16316 KB
01_random_03.txt AC 76 ms 16040 KB
01_random_04.txt AC 75 ms 16156 KB
01_random_05.txt AC 74 ms 16088 KB
01_random_06.txt AC 75 ms 16228 KB
01_random_07.txt AC 74 ms 16260 KB
01_random_08.txt AC 75 ms 16216 KB
01_random_09.txt AC 78 ms 16348 KB
01_random_10.txt AC 75 ms 16152 KB
01_random_11.txt AC 75 ms 16236 KB
01_random_12.txt AC 75 ms 16188 KB
01_random_13.txt AC 75 ms 16352 KB
01_random_14.txt AC 75 ms 16156 KB
01_random_15.txt AC 76 ms 16216 KB
01_random_16.txt AC 79 ms 16372 KB
01_random_17.txt AC 76 ms 16180 KB
01_random_18.txt AC 75 ms 16232 KB
01_random_19.txt AC 76 ms 16184 KB
02_random2_00.txt AC 128 ms 47440 KB
02_random2_01.txt AC 103 ms 16328 KB
02_random2_02.txt AC 61 ms 22956 KB
03_zero_00.txt AC 65 ms 25528 KB
03_zero_01.txt AC 82 ms 16032 KB
03_zero_02.txt AC 72 ms 16144 KB
04_handmade_00.txt AC 3 ms 3540 KB
04_handmade_01.txt AC 88 ms 19820 KB


2025-04-22 (Tue)
05:24:31 +00:00