欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1744B.Even-Odd Increments
Even-Odd Increments
You are given of integers . Process queries of two types:
- query of the form "
0 $x_j$": add the value to all even elements of the array , - query of the form "
1 $x_j$": add the value to all odd elements of the array .
Note that when processing the query, we look specifically at the odd/even value of , not its index.
After processing each query, print the sum of the elements of the array .
Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
Input
The first line of the input contains an integer ) — the number of test cases.
The descriptions of the test cases follow.
The first line of each test case contains two integers and (, ) — the length of array and the number of queries.
The second line of each test case contains exactly integers: () — elements of the array .
The following lines contain queries as two integers and , ).
It is guaranteed that the sum of values over all test cases in a test does not exceed . Similarly, the sum of values over all test cases does not exceed .
Output
For each test case, print numbers: the sum of the elements of the array after processing a query.
Note
In the first test case, the array after the first query.
In the third test case, the array is modified as follows: .
Samples
4
1 1
1
1 1
3 3
1 2 4
0 2
1 3
0 5
6 7
1 3 2 4 10 48
1 6
0 5
0 4
0 5
1 3
0 12
0 1
6 7
1000000000 1000000000 1000000000 11 15 17
0 17
1 10000
1 51
0 92
0 53
1 16
0 1
2
11
14
29
80
100
100
100
118
190
196
3000000094
3000060094
3000060400
3000060952
3000061270
3000061366
3000061366
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |