CF1791F.Range Update Point Query

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Given an array a1,a2,,ana_1, a_2, \dots, a_n , you need to handle a total of qq updates and queries of two types:

  • 11 ll rr — for each index ii with lirl \leq i \leq r , update the value of aia_i to the sum of the digits of aia_i .
  • 22 xx — output axa_x .

输入格式

The first line of the input contains an integer tt ( 1t10001 \leq t \leq 1000 ) — the number of testcases.

The first line of each test case contains two integers nn and qq ( 1n,q21051 \le n, q \le 2 \cdot 10^5 ) — the size of the array and the number of queries, respectively.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1091 \le a_i \le 10^9 ).

The next qq lines of each test case are of two forms:

  • 11 ll rr ( 1lrn1 \leq l \leq r \leq n ) — it means, for each index ii with lirl \leq i \leq r , you should update the value of aia_i to the sum of its digits.
  • 22 xx ( 1xn1 \leq x \leq n ) — it means you should output axa_x .

There is at least one query of the second type.

The sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

The sum of qq over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

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]a = [1, 420, 69, 1434, 2023] .
  • The operation is performed for l=2l=2 , r=3r=3 , yielding [1,6,15,1434,2023][1, \textcolor{red}{6}, \textcolor{red}{15}, 1434, 2023] .
  • We are queried for x=2x=2 , x=3x=3 , and x=4x=4 , and output 66 , 1515 , and 14341434 .
  • The operation is performed for l=2l=2 , r=5r=5 , yielding [1,6,6,12,7][1, \textcolor{red}{6}, \textcolor{red}{6}, \textcolor{red}{12}, \textcolor{red}{7}] .
  • We are queried for x=1x=1 , x=3x=3 , and x=5x=5 , and output 11 , 66 , and 77 .
首页