C. 异或变换

    Type: Default File IO: xor 1000ms 512MiB

异或变换

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给定两个长度为 nn 的非负整数数组 a,ba,b,定义一次操作为:

  • 选定一个数 ii,满足 1≤i≤n1\le i\le n;
  • 对于所有 1≤j≤n1\le j\le n 且 i≠ji\not= j,令 aj←aj⊕aia_j\gets a_j\oplus a_i,其中 ⊕\oplus 表示二进制异或。

问能否在有限次操作内使数组 aa 与 bb 相等。如果可以,输出 Yes;否则输出 No。

输入格式

从文件 xor.in 中读入数据。

本题有多组测试数据。

输入的第一行包含一个正整数 TT,表示数据组数。

接下来包含 TT 组数据,每组数据的格式如下:

第一行包含一个正偶数 nn,表示数组长度。

第二行包含 nn 个非负整数 a1,a2,…,ana_1, a_2, \dots, a_n,表示数组 aa 中的元素。

第三行包含 nn 个非负整数 b1,b2,…,bnb_1, b_2, \dots, b_n,表示数组 bb 中的元素。

输出格式

输出到文件 xor.out 中。

对于每组数据:输出一行包含一个字符串 Yes 或 No。

样例 1 输入

6
2
1 2
1 0
4
1 2 4 7
6 7 5 3
4
1 2 4 8
8 4 2 1
4
1 2 3 4
1 2 4 5
4
1 2 0 3
3 3 0 3
6
3 5 6 9 10 12
6 5 3 12 15 9

样例 1 输出

No
Yes
Yes
No
No
Yes

样例 1 解释

对于第二组数据,对 i=2,3,4i=2,3,4 分别操作一次可以使数组 aa 与 bb 相等。

样例 2

见选手目录下的 xor2.in 与 xor2.ans。

数据范围

对于所有测试数据,保证:nn 为偶数,1≤T≤101\leq T\leq 10,1≤n≤2×1051\leq n\leq 2\times 10^5,0≤ai,bi<2300\leq a_i,b_i< 2^{30}。

测试点 n≤n\le ai,bi<a_i,b_i< 特殊性质
1∼41\sim 4 66 88 无
5∼75\sim7 10001000 2102^{10}
8∼108\sim10 A
11∼1311\sim13 2×1052\times10^5 2302^{30}
14∼1614\sim16 2102^{10} 无
17∼2017\sim20 2302^{30}

特殊性质 A:保证所有 aia_i 均为 22 的幂次。

附件下载

20261007-赛后改题

Not Claimed
Status
Done
Problem
4
Open Since
2026-10-7 14:33
Deadline
2026-10-15 23:59
Extension
24 hour(s)