CF1791F.Range Update Point Query
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an array a1,a2,…,an , you need to handle a total of q updates and queries of two types:
- 1 l r — for each index i with l≤i≤r , update the value of ai to the sum of the digits of ai .
- 2 x — output ax .
输入格式
The first line of the input contains an integer t ( 1≤t≤1000 ) — the number of testcases.
The first line of each test case contains two integers n and q ( 1≤n,q≤2⋅105 ) — the size of the array and the number of queries, respectively.
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤109 ).
The next q lines of each test case are of two forms:
- 1 l r ( 1≤l≤r≤n ) — it means, for each index i with l≤i≤r , you should update the value of ai to the sum of its digits.
- 2 x ( 1≤x≤n ) — it means you should output ax .
There is at least one query of the second type.
The sum of n over all test cases does not exceed 2⋅105 .
The sum of q over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output the answers of queries of the second type, in the order they are given.
输入输出样例
输入#1
3 5 8 1 420 69 1434 2023 1 2 3 2 2 2 3 2 4 1 2 5 2 1 2 3 2 5 2 3 9999 1000 1 1 2 2 1 2 2 1 1 1 2 1
输出#1
6 15 1434 1 6 7 36 1 1
说明/提示
In the first test case, the following process occurs:
- Initially, a=[1,420,69,1434,2023] .
- The operation is performed for l=2 , r=3 , yielding [1,6,15,1434,2023] .
- We are queried for x=2 , x=3 , and x=4 , and output 6 , 15 , and 1434 .
- The operation is performed for l=2 , r=5 , yielding [1,6,6,12,7] .
- We are queried for x=1 , x=3 , and x=5 , and output 1 , 6 , and 7 .