結果

問題 No.1239 Multiplication -2
ユーザー chineristACchineristAC
提出日時 2020-10-01 16:21:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,434 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 105,628 KB
最終ジャッジ日時 2023-09-21 06:55:40
合計ジャッジ時間 9,669 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 72 ms
71,424 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 70 ms
71,320 KB
testcase_13 AC 72 ms
71,388 KB
testcase_14 AC 73 ms
71,540 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 92 ms
90,684 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
mod = 998244353
inv = pow(2,mod-2,mod)

res = 0

for i in range(N):
    if abs(A[i])==2:
        base = pow(2,max(i-1,0),mod)
        left_pos = base
        left_nega = 0
        prod = 1
        if i!=1:
            base = (base * inv) % mod
        for j in range(1,i+1):
            if abs(A[i-j])==1:
                prod *= A[i-j]
                if prod>0:
                    left_pos += base
                else:
                    left_nega += base
            else:
                break
            if j!=i-1:
                base = (base * inv) % mod

        base = pow(2,max(0,N-i-2),mod)
        right_pos = base
        right_nega = 0
        prod = 1
        if i!=N-2:
            base = (base * inv) % mod
        for j in range(1,N-i):
            print(base)
            if abs(A[i+j])==1:
                prod *= A[i+j]
                if prod>0:
                    right_pos += base
                else:
                    right_nega += base
            else:
                break
            if j!=N-i-2:
                base = (base * inv) % mod

        if A[i]==2:
            res += left_pos * right_nega + left_nega * right_pos
        else:
            res += left_pos * right_pos + left_nega * right_nega
        res %= mod
        #print(left_pos,left_nega,right_pos,right_nega)

#print(res)
ans = res * pow(2,(N-1)*(mod-2),mod)
print(ans%mod)
0