Universal Cup Judging System

Universal Cup

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

길이가 $n$ ($n \ge 2$)인 정수 수열 $a_{1,2,\ldots,n}$과 길이가 $m$ ($m \ge 2$)인 정수 수열 $b_{1,2,\ldots,m}$이 주어질 때, $c_{i,j} = a_i \oplus b_j$ ($1 \le i \le n, 1 \le j \le m$)를 만족하는 $n \times m$ 행렬 $c$를 구성할 수 있습니다. 여기서 $\oplus$는 비트 XOR 연산을 나타냅니다.

$c$의 부분 직사각형 영역 $\begin{bmatrix} c_{i,j} & c_{i,j+1} \\ c_{i+1,j} & c_{i+1,j+1} \end{bmatrix}$이 $\begin{bmatrix} x & x + 1 \\ x + 2 & x + 3 \end{bmatrix}$ 형태가 되는, 즉 $c_{i,j+1} = c_{i,j} + 1$, $c_{i+1,j} = c_{i,j} + 2$, 그리고 $c_{i+1,j+1} = c_{i,j} + 3$을 만족하는 순서쌍 $(i, j)$ ($1 \le i < n, 1 \le j < m$)가 몇 개인지 구하십시오.

입력

첫째 줄에 테스트 케이스의 수를 나타내는 정수 $T$ ($1 \le T \le 10^5$)가 주어집니다.

각 테스트 케이스에 대하여:

첫째 줄에 $c$의 행과 열의 개수를 나타내는 공백으로 구분된 두 정수 $n, m$ ($2 \le n, m \le 2 \times 10^5$)이 주어집니다.

둘째 줄에 $a_1, a_2, \ldots, a_n$ ($0 \le a_i < 2^{30}$)을 나타내는 공백으로 구분된 $n$개의 정수가 주어집니다.

셋째 줄에 $b_1, b_2, \ldots, b_m$ ($0 \le b_i < 2^{30}$)을 나타내는 공백으로 구분된 $m$개의 정수가 주어집니다.

모든 테스트 케이스에서 $n$의 합은 $2 \times 10^5$을 넘지 않으며 $m$의 합도 $2 \times 10^5$을 넘지 않음이 보장됩니다.

출력

각 테스트 케이스마다 조건을 만족하는 순서쌍 $(i, j)$의 개수를 나타내는 정수를 한 줄에 출력합니다.

예제

입력 1

5
2 2
0 2
0 1
3 3
6 4 2
6 7 10
5 4
4 6 5 1 3
1 0 2 3
7 2
7 3 1 4 0 0 1
6 5
5 5
1 7 5 3 1
3 2 7 7 6

출력 1

1
2
1
0
6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.