問題一覧 > 通常問題

No.1863 Xor Sum 2...?

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 84
作問者 : NaHCO314 / テスター : shiomusubi496 MtSaka
お気に入りにしたユーザー ProblemId : 6234 / 自分の提出
問題文最終更新日: 2022-03-04 20:29:00
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 334 (順位表) の他の問題:

Problem Statement

You are given sequences of positive integers $A,B$ of length $N$. $B$ is a sequence consisting only of $0$ and $1$.

Find the number of pairs of integers $l,r(1\leq l\leq r\leq N)$ that satisfy the following condition.

  • $(A_l+A_{l+1}+\cdots+A_r)-(A_l\oplus A_{l+1}\oplus\cdots\oplus A_r)=B_l\oplus B_{l+1}\oplus\cdots\oplus B_r$

Here, $a \oplus b$ denotes the bitwise exclusive OR of $a$ and $b$.

Input

$N$
$A_1$ $A_2$ $\ldots$ $A_N$
$B_1$ $B_2$ $\ldots$ $B_N$
  • All inputs are integers.
  • $1\leq N\leq 10^5$
  • $1\leq A_i\leq 10^9$
  • $B_i$ is $0$ or $1$.

Output

Print a newline at the end.

Sample

Sample 1
Input
5
3 2 1 4 6
1 0 0 1 0
Output
4

$(l,r)=(2,2),(2,3),(3,3),(5,5)$ satisfy the condition.

Sample 2
Input
1
334
1
Output
0

No pair satisfies the condition.

Sample 3
Input
10
3 1 4 1 5 9 2 6 5 3
0 0 0 0 0 0 0 0 0 0
Output
13

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。