結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー Eliza_0xEliza_0x
提出日時 2018-05-13 14:46:52
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 594 bytes
コンパイル時間 962 ms
コンパイル使用メモリ 161,848 KB
実行使用メモリ 817,968 KB
最終ジャッジ日時 2023-09-10 18:49:49
合計ジャッジ時間 6,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,740 KB
testcase_01 AC 22 ms
14,988 KB
testcase_02 AC 43 ms
24,068 KB
testcase_03 AC 42 ms
24,036 KB
testcase_04 AC 12 ms
11,636 KB
testcase_05 AC 42 ms
24,180 KB
testcase_06 AC 22 ms
15,712 KB
testcase_07 MLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Bits
import Data.Array

main  = do
    n <- read <$> getLine :: IO Int
    ns <- listArray (1,n) . map read . words <$> getLine :: IO (Array Int Int)
    let memo = dp ns 0 n (listArray (0,1) [])
    print . sum $ [if memo!i then 1 else 0 | i<-[0..r]]

r = 16384

dp :: Array Int Int -> Int -> Int -> Array Int Bool -> Array Int Bool
dp ns y n memo = if y > n 
    then memo 
    else dp ns (y+1) n memo'
    where
    memo' = array (0,r) $ [(x, f y x)|x<-[0..r]]
    f 0 0 = True
    f 0 _ = False
    f y x = memo!x || (if x `xor` ns!y < r then memo!(x `xor` (ns!y)) else False)

0