結果

問題 No.1741 Arrays and XOR Procedure
ユーザー とりゐとりゐ
提出日時 2021-10-16 13:16:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 628 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 105,304 KB
最終ジャッジ日時 2023-08-16 20:46:54
合計ジャッジ時間 16,835 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,096 KB
testcase_01 AC 70 ms
71,136 KB
testcase_02 AC 70 ms
71,088 KB
testcase_03 AC 628 ms
105,304 KB
testcase_04 AC 72 ms
71,212 KB
testcase_05 AC 627 ms
104,872 KB
testcase_06 AC 624 ms
105,080 KB
testcase_07 AC 620 ms
105,032 KB
testcase_08 AC 610 ms
104,956 KB
testcase_09 AC 513 ms
101,668 KB
testcase_10 AC 535 ms
101,784 KB
testcase_11 AC 460 ms
96,156 KB
testcase_12 AC 372 ms
91,168 KB
testcase_13 AC 521 ms
101,676 KB
testcase_14 AC 432 ms
93,592 KB
testcase_15 AC 472 ms
98,748 KB
testcase_16 AC 127 ms
77,696 KB
testcase_17 AC 245 ms
84,320 KB
testcase_18 AC 435 ms
93,828 KB
testcase_19 AC 129 ms
77,636 KB
testcase_20 AC 589 ms
104,944 KB
testcase_21 AC 458 ms
98,800 KB
testcase_22 AC 408 ms
96,092 KB
testcase_23 AC 226 ms
82,604 KB
testcase_24 AC 141 ms
77,792 KB
testcase_25 AC 586 ms
104,892 KB
testcase_26 AC 286 ms
86,484 KB
testcase_27 AC 112 ms
78,260 KB
testcase_28 AC 443 ms
96,168 KB
testcase_29 AC 523 ms
99,028 KB
testcase_30 AC 437 ms
96,252 KB
testcase_31 AC 119 ms
77,672 KB
testcase_32 AC 300 ms
86,256 KB
testcase_33 AC 337 ms
89,840 KB
testcase_34 AC 191 ms
81,032 KB
testcase_35 AC 94 ms
76,460 KB
testcase_36 AC 135 ms
77,716 KB
testcase_37 AC 289 ms
86,376 KB
testcase_38 AC 593 ms
105,176 KB
testcase_39 AC 291 ms
85,144 KB
testcase_40 AC 113 ms
77,508 KB
testcase_41 AC 206 ms
80,320 KB
testcase_42 AC 139 ms
78,252 KB
testcase_43 AC 69 ms
71,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def base10int(n,base):
  x=[]
  while n!=0:
    x.append(n%base)
    n//=base
  return x[::-1]

def comb(n,r):
  if r>n:
    return 0
  tmp1=1
  tmp2=1
  for i in range(r):
    tmp1*=n-i
    tmp2*=i+1
  return tmp1//tmp2

def lucas(n,k,p):
  # nCk mod p を求める
  np=base10int(n,p)
  kp=base10int(k,p)
  kp=[0]*(len(np)-len(kp))+kp
  tmp=1
  for ni,ki in zip(np,kp):
    tmp*=comb(ni,ki)
    tmp%=p
  return tmp

n=int(input())
b=list(map(int,input().split()))
mod=998244353
dp=[1,0]
for i in range(n):
  m=lucas(n-1,i,2)
  if b[i]==0:
    pass
  if b[i]==1:
    if m==1:
      dp=[dp[1],dp[0]]
  if b[i]==-1:
    if m==0:
      dp=[2*dp[0]%mod,2*dp[1]%mod]
    else:
      dp=[(dp[0]+dp[1])%mod]*2
print(dp[1])
0