Logo
(追記) (追記ここまで)

21266번 - Bit Operation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB1371014984.483%

문제

You are given an integer array $A$ of length $N,ドル consisting of 0ドル$'s and 1ドル$'s. Let $a$ be initially the array $A$. You are going to perform the following operation $N-1$ times.

  • Let $n$ be the current length of $a$. Choose an integer $i$ (1ドル \leq i \leq n-1$) and delete the $i$-th and the $(i+1)$-th elements of $a$. Then, by letting $x$ and $y$ be the deleted elements, insert either $x\mathbin{\&}y$ or $x\mathbin{|}y$ to the position of the deleted elements. Here $x\mathbin{\&}y$ and $x\mathbin{|}y$ denote the bit-AND and bit-OR operations, respectively.

There are 2ドル^{N-1} \times (N-1)!$ ways to perform the operations. Count the number of ways that result in a single value of 1ドル,ドル modulo 998244353ドル$.

입력

The first line contains an integer $N$ (1ドル \leq N \leq 10^6$).

The second line contains integers $A_1,A_2,\ldots,A_N$ (0ドル \leq A_i \leq 1$).

출력

Print the answer.

제한

예제 입력 1

3
0 1 0

예제 출력 1

2

예제 입력 2

5
1 1 1 1 1

예제 출력 2

384

예제 입력 3

7
0 1 1 0 1 0 1

예제 출력 3

25515

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 14: Grand Prix of Tokyo B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /