Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

กำหนดลำดับจำนวนเต็มความยาว $n$ ($n \ge 2$) แทนด้วย $a_{1,2,\ldots,n}$ และลำดับจำนวนเต็มความยาว $m$ ($m \ge 2$) แทนด้วย $b_{1,2,\ldots,m}$ เราสามารถสร้างเมทริกซ์ $c$ ขนาด $n \times m$ โดยที่ $c_{i,j} = a_i \oplus b_j$ ($1 \le i \le n, 1 \le j \le m$) เมื่อ $\oplus$ แทนการดำเนินการ XOR ระดับบิต

จงหาว่ามีคู่ลำดับ $(i, j)$ ($1 \le i < n, 1 \le j < m$) กี่คู่ที่ทำให้บริเวณสี่เหลี่ยมมุมฉากย่อยของ $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$

ข้อมูลนำเข้า

บรรทัดแรกประกอบด้วยจำนวนเต็ม $T$ ($1 \le T \le 10^5$) แทนจำนวนกรณีทดสอบ

สำหรับแต่ละกรณีทดสอบ:

บรรทัดแรกประกอบด้วยจำนวนเต็มสองตัวคั่นด้วยช่องว่าง $n, m$ ($2 \le n, m \le 2 \times 10^5$) แทนจำนวนแถวและคอลัมน์ของ $c$

บรรทัดที่สองประกอบด้วยจำนวนเต็ม $n$ ตัวคั่นด้วยช่องว่าง แทน $a_1, a_2, \ldots, a_n$ ($0 \le a_i < 2^{30}$)

บรรทัดที่สามประกอบด้วยจำนวนเต็ม $m$ ตัวคั่นด้วยช่องว่าง แทน $b_1, b_2, \ldots, b_m$ ($0 \le b_i < 2^{30}$)

รับประกันว่าผลรวมของ $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.