結果

問題 No.1741 Arrays and XOR Procedure
ユーザー dn6049949dn6049949
提出日時 2021-11-14 22:29:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 1,155 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 95,284 KB
最終ジャッジ日時 2023-08-20 07:25:27
合計ジャッジ時間 10,459 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
71,384 KB
testcase_01 AC 112 ms
71,800 KB
testcase_02 AC 113 ms
71,520 KB
testcase_03 AC 163 ms
95,284 KB
testcase_04 AC 96 ms
71,728 KB
testcase_05 AC 175 ms
94,600 KB
testcase_06 AC 158 ms
94,780 KB
testcase_07 AC 157 ms
95,000 KB
testcase_08 AC 149 ms
94,520 KB
testcase_09 AC 149 ms
92,768 KB
testcase_10 AC 153 ms
92,896 KB
testcase_11 AC 149 ms
89,664 KB
testcase_12 AC 140 ms
86,648 KB
testcase_13 AC 153 ms
92,500 KB
testcase_14 AC 145 ms
88,068 KB
testcase_15 AC 145 ms
91,268 KB
testcase_16 AC 115 ms
77,576 KB
testcase_17 AC 126 ms
82,396 KB
testcase_18 AC 145 ms
88,404 KB
testcase_19 AC 116 ms
77,612 KB
testcase_20 AC 158 ms
94,932 KB
testcase_21 AC 147 ms
90,560 KB
testcase_22 AC 141 ms
89,812 KB
testcase_23 AC 127 ms
81,908 KB
testcase_24 AC 118 ms
77,900 KB
testcase_25 AC 157 ms
94,804 KB
testcase_26 AC 130 ms
83,752 KB
testcase_27 AC 113 ms
77,668 KB
testcase_28 AC 143 ms
89,584 KB
testcase_29 AC 157 ms
91,164 KB
testcase_30 AC 146 ms
89,696 KB
testcase_31 AC 111 ms
77,728 KB
testcase_32 AC 130 ms
83,820 KB
testcase_33 AC 132 ms
85,708 KB
testcase_34 AC 117 ms
79,880 KB
testcase_35 AC 108 ms
77,344 KB
testcase_36 AC 113 ms
78,004 KB
testcase_37 AC 129 ms
83,612 KB
testcase_38 AC 159 ms
94,332 KB
testcase_39 AC 130 ms
82,984 KB
testcase_40 AC 115 ms
77,744 KB
testcase_41 AC 123 ms
80,708 KB
testcase_42 AC 116 ms
77,856 KB
testcase_43 AC 95 ms
71,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 998244353

def main():
    def lucas(a,b):
        return 1*(a&b == b)

    n = I()
    b = LI()
    c = [lucas(n-1,i) for i in range(n)]
    dp = [0]*2
    dp[0] = 1
    for bi,ci in zip(b,c):
        ndp = [0]*2
        for j in range(2):
            for i in range(2):
                if bi >= 0 and bi != i:
                    continue
                if ci:
                    nj = j^i
                else:
                    nj = j
                ndp[nj] = (ndp[nj]+dp[j])%mod
        dp = ndp
    print(dp[1])
    return


if __name__ == "__main__":
    main()
0