結果
問題 |
No.1741 Arrays and XOR Procedure
|
ユーザー |
![]() |
提出日時 | 2022-06-14 05:26:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 23,796 KB |
最終ジャッジ日時 | 2024-10-01 21:10:19 |
合計ジャッジ時間 | 4,565 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
import sys input = sys.stdin.readline N=int(input()) B=list(map(int,input().split())) mod=998244353 ONE1=0 ONEm1=0 ZEROm1=0 for i in range(N): if ((N-1)&i)==i: # N-1 C iの偶奇が奇数のときをこれで判定できる if B[i]==1: ONE1+=1 elif B[i]==-1: ONEm1+=1 else: if B[i]==-1: ZEROm1+=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)