結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
24,128 KB
testcase_01 AC 52 ms
35,052 KB
testcase_02 AC 183 ms
78,996 KB
testcase_03 AC 153 ms
68,388 KB
testcase_04 AC 52 ms
32,668 KB
testcase_05 AC 194 ms
78,912 KB
testcase_06 AC 83 ms
39,036 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)
    print $ dp ns

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