欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1869A.Make It Zero
Make It Zero
During Zhongkao examination, Reycloer met an interesting problem, but he cannot come up with a solution immediately. Time is running out! Please help him.
Initially, you are given an array consisting of integers, and you want to change all elements in it to .
In one operation, you select two indices and () and do the following:
- Let , where denotes the bitwise XOR operation;
- Then, for all , replace with .
You can use the operation above in any order at most times in total.
Find a sequence of operations, such that after performing the operations in order, all elements in are equal to . It can be proven that the solution always exists.
Input
The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains integers () — the elements of the array .
Output
For each test case, in the first line output a single integer () — the number of operations you use.
Then print lines, in the -th line output two integers and () representing that you select and in the -th operation.
Note that you do not have to minimize . If there are multiple solutions, you may output any of them.
Note
In the first test case, since , after performing the operation on segment , all the elements in the array are equal to .
In the second test case, after the first operation, the array becomes equal to , after the second operation, the array becomes equal to .
In the third test case:
| Operation | before | after | |
|---|---|---|---|
In the fourth test case, the initial array contains only , so we do not need to perform any operations with it.
Samples
6
4
1 2 3 0
8
3 1 4 1 5 9 2 6
6
1 5 4 1 4 7
5
0 0 0 0 0
7
1 1 9 9 0 1 8
3
100 100 0
1
1 4
2
4 7
1 8
6
1 2
3 4
5 6
1 3
4 6
1 6
0
4
1 2
6 7
3 4
6 7
1
1 2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |