結果

問題 No.1741 Arrays and XOR Procedure
ユーザー とりゐとりゐ
提出日時 2021-10-16 13:16:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 537 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 104,448 KB
最終ジャッジ日時 2024-05-04 04:11:04
合計ジャッジ時間 13,902 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 521 ms
104,320 KB
testcase_04 AC 37 ms
52,224 KB
testcase_05 AC 525 ms
103,424 KB
testcase_06 AC 525 ms
104,448 KB
testcase_07 AC 537 ms
104,320 KB
testcase_08 AC 509 ms
103,680 KB
testcase_09 AC 460 ms
100,992 KB
testcase_10 AC 466 ms
100,864 KB
testcase_11 AC 406 ms
94,720 KB
testcase_12 AC 310 ms
90,496 KB
testcase_13 AC 453 ms
100,352 KB
testcase_14 AC 364 ms
92,416 KB
testcase_15 AC 412 ms
98,048 KB
testcase_16 AC 103 ms
76,800 KB
testcase_17 AC 204 ms
83,072 KB
testcase_18 AC 367 ms
92,544 KB
testcase_19 AC 106 ms
76,676 KB
testcase_20 AC 523 ms
104,320 KB
testcase_21 AC 387 ms
97,408 KB
testcase_22 AC 367 ms
94,720 KB
testcase_23 AC 200 ms
81,748 KB
testcase_24 AC 114 ms
76,416 KB
testcase_25 AC 490 ms
103,552 KB
testcase_26 AC 242 ms
85,248 KB
testcase_27 AC 86 ms
76,288 KB
testcase_28 AC 364 ms
94,848 KB
testcase_29 AC 464 ms
97,792 KB
testcase_30 AC 385 ms
95,360 KB
testcase_31 AC 94 ms
76,288 KB
testcase_32 AC 261 ms
85,248 KB
testcase_33 AC 296 ms
88,960 KB
testcase_34 AC 164 ms
79,744 KB
testcase_35 AC 76 ms
69,376 KB
testcase_36 AC 122 ms
76,928 KB
testcase_37 AC 255 ms
85,120 KB
testcase_38 AC 506 ms
103,936 KB
testcase_39 AC 252 ms
83,840 KB
testcase_40 AC 85 ms
76,672 KB
testcase_41 AC 174 ms
79,488 KB
testcase_42 AC 113 ms
76,544 KB
testcase_43 AC 37 ms
52,352 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