結果

問題 No.1741 Arrays and XOR Procedure
ユーザー titiatitia
提出日時 2022-06-14 05:18:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,197 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 24,032 KB
最終ジャッジ日時 2024-04-09 20:40:37
合計ジャッジ時間 25,527 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 27 ms
11,008 KB
testcase_02 AC 28 ms
11,008 KB
testcase_03 AC 1,197 ms
24,032 KB
testcase_04 AC 27 ms
11,008 KB
testcase_05 AC 1,123 ms
14,760 KB
testcase_06 AC 1,147 ms
19,320 KB
testcase_07 AC 1,149 ms
19,324 KB
testcase_08 AC 1,137 ms
14,892 KB
testcase_09 AC 991 ms
16,304 KB
testcase_10 AC 1,032 ms
16,436 KB
testcase_11 AC 783 ms
15,416 KB
testcase_12 AC 605 ms
14,468 KB
testcase_13 AC 961 ms
16,248 KB
testcase_14 AC 675 ms
14,872 KB
testcase_15 AC 904 ms
16,040 KB
testcase_16 AC 69 ms
11,264 KB
testcase_17 AC 320 ms
12,928 KB
testcase_18 AC 719 ms
15,044 KB
testcase_19 AC 61 ms
11,264 KB
testcase_20 AC 1,131 ms
17,872 KB
testcase_21 AC 844 ms
15,656 KB
testcase_22 AC 763 ms
15,340 KB
testcase_23 AC 290 ms
12,544 KB
testcase_24 AC 84 ms
11,264 KB
testcase_25 AC 1,090 ms
17,748 KB
testcase_26 AC 449 ms
13,816 KB
testcase_27 AC 62 ms
11,264 KB
testcase_28 AC 814 ms
15,516 KB
testcase_29 AC 931 ms
16,216 KB
testcase_30 AC 797 ms
15,452 KB
testcase_31 AC 64 ms
11,392 KB
testcase_32 AC 445 ms
13,696 KB
testcase_33 AC 550 ms
14,112 KB
testcase_34 AC 208 ms
12,032 KB
testcase_35 AC 30 ms
10,880 KB
testcase_36 AC 102 ms
11,392 KB
testcase_37 AC 421 ms
13,172 KB
testcase_38 AC 1,072 ms
17,016 KB
testcase_39 AC 358 ms
13,056 KB
testcase_40 AC 34 ms
10,880 KB
testcase_41 AC 184 ms
11,776 KB
testcase_42 AC 62 ms
11,136 KB
testcase_43 AC 27 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
B=list(map(int,input().split()))

mod=998244353

# Lucasの定理
# 素数pと非負整数m, nに対して、Combi(m,n) mod pを求める。
# https://manabitimes.jp/math/1324
# modを取らない二項係数の計算は予め容易しておく。
# ここでの実装はパスカルの三角形を使ったもの。

Combi=[[] for i in range(100+1)]
Combi[0]=[1,0]

for i in range(1,100+1):
    Combi[i].append(1)
    for j in range(i):
        Combi[i].append(Combi[i-1][j]+Combi[i-1][j+1])
    Combi[i].append(0)

def p_rep(p,x):
    ANS=[]
    for i in range(100):
        ANS.append(x%p)
        x//=p

        if x==0:
            break
    return ANS

def Combi_mod_p(m,n,p):
    ANS=1

    A=p_rep(p,m)
    B=p_rep(p,n)

    for i in range(min(len(A),len(B))):
        ANS=ANS*Combi[A[i]][B[i]]%p

    return ANS

ONE1=0
ONEm1=0
ZEROm1=0

for i in range(N):
    if Combi_mod_p(N-1,i,2)==0:
        if B[i]==-1:
            ZEROm1+=1
    else:
        if B[i]==1:
            ONE1+=1
        elif B[i]==-1:
            ONEm1+=1


ANS=pow(2,ZEROm1,mod)

if ONEm1==0:
    if ONE1%2==1:
        ANS2=1
    else:
        ANS2=0
else:
    ANS2=pow(2,ONEm1,mod)*pow(2,mod-2,mod)

print(ANS*ANS2%mod)
        
0