#P8279. 「MCOI-08」Fill In REMATCH

    ID: 7260 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>洛谷原创Special JudgeO2优化位运算,按位构造洛谷月赛

「MCOI-08」Fill In REMATCH

题目描述

Dream 有一个长度为 nn1n1051\le n\le 10^5)的整数数组 a1,a2,,ana_1,a_2,\dots,a_n,其中对于 i=1,2,,ni=1,2,\dots,n,满足 0ai<2600\le a_i<2^{60}

他计算了前缀异或数组 pi=a1a2aip_i=a_1\oplus a_2\oplus\dots\oplus a_i 以及后缀异或数组 si=aiai+1ans_i=a_i\oplus a_{i+1}\oplus\dots\oplus a_n

现在 Tommy 一共ppssnn 个元素换成 1-1。给定当前的 ppss 数组,请恢复任意一组可能为原数组的 a1,a2,,ana_1,a_2,\dots,a_n

保证存在一组合法解。

输入格式

本题有多组数据,第一行一个正整数 tt,为数据组数。接下来 tt 组数据,其中对于每一组数据:

第一行一个正整数 nn1n1051\le n\le 10^5)。

接下来 nn 个整数 p1,p2,,pnp_1,p_2,\dots,p_n

接下来 nn 个整数 s1,s2,,sns_1,s_2,\dots,s_n

输出格式

对于每一组数据:

输出 nn 个非负整数 a1,a2,,ana_1,a_2,\dots,a_n,满足以上条件。

1
4
-1 34 367 -1
3178 -1 -1 3333
3 33 333 3333

提示

对于 100%100\% 的数据,1n,n1051\le n,\sum n\le 10^5[pi=1]+[si=1]=n\sum [p_i=-1]+\sum [s_i=-1]=n保证有合法解。

  • Subtask 1(10 pts):n4n\le 4pi,si<2p_i,s_i<2
  • Subtask 2(10 pts):n100n\le 100
  • Subtask 3(20 pts):pi,si<2p_i,s_i<2
  • Subtask 4(60 pts):无特殊限制。