欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1872E.Data Structures Fan
Data Structures Fan
You are given an array of integers , as well as a binary string consisting of characters.
Augustin is a big fan of data structures. Therefore, he asked you to implement a data structure that can answer queries. There are two types of queries:
- "1 " () — replace each character for with its opposite. That is, replace all
0with1and all1with0. - "2 " () — calculate the value of the bitwise XOR of the numbers for all indices such that . Note that the of an empty set of numbers is considered to be equal to .
Please help Augustin to answer all the queries!
For example, if , , , consider the following series of queries:
- "2 " — we are interested in the indices for which , since , these are the indices and , so the answer to the query will be .
- "1 " — we need to replace the characters with their opposites, so before the query , and after the query: .
- "2 " — we are interested in the indices for which , since , these are the indices , , and , so the answer to the query will be $a_2 \oplus a_3 \oplus a_4 = 2 \oplus 3 \oplus 6 = 7$.
- "1 " — .
- "2 " — , there are no indices with , so since the of an empty set of numbers is considered to be equal to , the answer to this query is .
A binary string is a string containing only characters 0 or 1.
Input
The first line of the input contains one integer () — the number of test cases in the test.
The descriptions of the test cases follow.
The first line of each test case description contains an integer () — the length of the array.
The second line of the test case contains integers ().
The third line of the test case contains the binary string of length .
The fourth line of the test case contains one integer () — the number of queries.
The subsequent lines of the test case describe the queries. The first number of each query, , characterizes the type of the query: if , then integers follow, meaning that the operation of type should be performed with parameters , and if , then one integer follows, meaning that the operation of type should be performed with parameter .
It is guaranteed that the sum of over all test cases does not exceed , and also that the sum of over all test cases does not exceed .
Output
For each test case, and for each query of type in it, output the answer to the corresponding query.
Note
Let's analyze the first test case:
- "2 " — we are interested in the indices for which , since , these are the indices , and , so the answer to the query will be $a_1 \oplus a_3 \oplus a_4 \oplus a_5 = 1 \oplus 3 \oplus 4 \oplus 5 = 3$.
- "2 " — we are interested in the indices for which , since , the only suitable index is , so the answer to the query will be .
- "1 " — we need to replace the characters with their opposites, so before the query , and after the query: .
- "2 " — we are interested in the indices for which , since , these are the indices , and , so the answer to the query will be $a_1 \oplus a_2 \oplus a_5 = 1 \oplus 2 \oplus 5 = 6$.
- "2 " — we are interested in the indices for which , since , these are the indices and , so the answer to the query will be .
- "1 " — .
- "2 " — we are interested in the indices for which , since , these are the indices , and , so the answer to the query will be $a_1 \oplus a_2 \oplus a_4 = 1 \oplus 2 \oplus 4 = 7$.
Samples
5
5
1 2 3 4 5
01000
7
2 0
2 1
1 2 4
2 0
2 1
1 1 3
2 1
6
12 12 14 14 5 5
001001
3
2 1
1 2 4
2 1
4
7 7 7 777
1111
3
2 0
1 2 3
2 0
2
1000000000 996179179
11
1
2 1
5
1 42 20 47 7
00011
5
1 3 4
1 1 1
1 3 4
1 2 4
2 0
3 2 6 7 7
11 7
0 0
16430827
47
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |