結果

問題 No.3070 Collecting Coins Speedrun 2
ユーザー Shirotsume
提出日時 2025-03-21 22:13:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 87,040 KB
最終ジャッジ日時 2025-03-21 22:13:48
合計ジャッジ時間 3,368 ms
ジャッジサーバーID
(参考情報)
judge2 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import e
import sys, time, random
from collections import deque, Counter, defaultdict
def debug(*x):print('debug:',*x, file=sys.stderr)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

n = ii()

c = li()

if 0 in c:
    z = True
    c.remove(0)
else:
    z = False
    
if len(c) == 0:
    print(1)
    exit()
    
if min(c) > 0 or max(c) < 0:
    ans = pow(2, len(c) - 1, mod)
    ans *= (z + 1)
    ans %= mod
    print(ans)
    exit()
    
    
plus = 0
minus = 0

for v in c:
    if v > 0:
        plus += 1
    else:
        minus += 1
        
#p-m

ans = 2 * pow(2, plus - 1, mod) * pow(2, minus - 1, mod)
if z:
    ans *= 3
    
print(ans % mod)
0