結果

問題 No.1741 Arrays and XOR Procedure
ユーザー wolgnikwolgnik
提出日時 2021-11-12 22:47:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 131,712 KB
最終ジャッジ日時 2024-05-04 10:20:34
合計ジャッジ時間 7,129 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
51,968 KB
testcase_01 AC 41 ms
51,712 KB
testcase_02 AC 42 ms
52,480 KB
testcase_03 AC 190 ms
131,712 KB
testcase_04 AC 47 ms
52,480 KB
testcase_05 WA -
testcase_06 AC 194 ms
131,328 KB
testcase_07 AC 154 ms
131,072 KB
testcase_08 AC 112 ms
127,104 KB
testcase_09 AC 157 ms
124,672 KB
testcase_10 AC 153 ms
124,928 KB
testcase_11 AC 137 ms
113,664 KB
testcase_12 AC 131 ms
104,960 KB
testcase_13 AC 161 ms
124,160 KB
testcase_14 AC 135 ms
108,288 KB
testcase_15 AC 163 ms
118,656 KB
testcase_16 AC 86 ms
76,488 KB
testcase_17 AC 115 ms
89,472 KB
testcase_18 AC 138 ms
108,800 KB
testcase_19 AC 95 ms
76,672 KB
testcase_20 AC 192 ms
130,688 KB
testcase_21 AC 160 ms
116,220 KB
testcase_22 AC 150 ms
113,892 KB
testcase_23 AC 110 ms
87,860 KB
testcase_24 AC 81 ms
76,160 KB
testcase_25 AC 177 ms
130,560 KB
testcase_26 AC 119 ms
95,144 KB
testcase_27 WA -
testcase_28 AC 149 ms
114,048 KB
testcase_29 AC 162 ms
119,040 KB
testcase_30 AC 145 ms
113,664 KB
testcase_31 WA -
testcase_32 AC 112 ms
94,464 KB
testcase_33 AC 117 ms
101,132 KB
testcase_34 AC 94 ms
83,276 KB
testcase_35 WA -
testcase_36 AC 77 ms
76,844 KB
testcase_37 AC 113 ms
94,720 KB
testcase_38 AC 161 ms
127,488 KB
testcase_39 AC 101 ms
91,008 KB
testcase_40 AC 62 ms
66,176 KB
testcase_41 AC 87 ms
82,176 KB
testcase_42 AC 81 ms
76,544 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 998244353

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]: self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i): return self.f[i]
  def ifactorial(self, i): return self.i[i]
  def combi(self, n, k): return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k): return self.f[n] * self.i[n - k] % self.mod

f = Factorial(N, 2)

def lucas(n, k):
  res = 1
  while n and k:
    res &= f.combi(n % 2, k % 2)
    n >>= 1
    k >>= 1
  return res

dp = [0] * 2
dp[0] = 1
for i in range(N):
  if a[i] == 1:
    c = lucas(N - 1, i)
    if c: dp[0], dp[1] = dp[1], dp[0]
  if a[i] == -1:
    c = lucas(N - 1, i)
    if c: dp[0], dp[1] = dp[0] * 2 % mod, dp[1] * 2 % mod
    else: dp[0], dp[1] = (dp[0] + dp[1]) % mod, (dp[0] + dp[1]) % mod
print(dp[-1])
0