CF1093G.Multidimensional Queries

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given an array aa of nn points in kk -dimensional space. Let the distance between two points axa_x and aya_y be i=1kax,iay,i\sum \limits_{i = 1}^{k} |a_{x, i} - a_{y, i}| (it is also known as Manhattan distance).

You have to process qq queries of the following two types:

  • 11 ii b1b_1 b2b_2 ... bkb_k — set ii -th element of aa to the point (b1,b2,,bk)(b_1, b_2, \dots, b_k) ;
  • 22 ll rr — find the maximum distance between two points aia_i and aja_j , where li,jrl \le i, j \le r .

输入格式

The first line contains two numbers nn and kk ( 1n21051 \le n \le 2 \cdot 10^5 , 1k51 \le k \le 5 ) — the number of elements in aa and the number of dimensions of the space, respectively.

Then nn lines follow, each containing kk integers ai,1a_{i, 1} , ai,2a_{i, 2} , ..., ai,ka_{i, k} ( 106ai,j106-10^6 \le a_{i, j} \le 10^6 ) — the coordinates of ii -th point.

The next line contains one integer qq ( 1q21051 \le q \le 2 \cdot 10^5 ) — the number of queries.

Then qq lines follow, each denoting a query. There are two types of queries:

  • 11 ii b1b_1 b2b_2 ... bkb_k ( 1in1 \le i \le n , 106bj106-10^6 \le b_j \le 10^6 ) — set ii -th element of aa to the point (b1,b2,,bk)(b_1, b_2, \dots, b_k) ;
  • 22 ll rr ( 1lrn1 \le l \le r \le n ) — find the maximum distance between two points aia_i and aja_j , where li,jrl \le i, j \le r .

There is at least one query of the second type.

输出格式

Print the answer for each query of the second type.

输入输出样例

  • 输入#1

    5 2
    1 2
    2 3
    3 4
    4 5
    5 6
    7
    2 1 5
    2 1 3
    2 3 5
    1 5 -1 -2
    2 1 5
    1 4 -1 -2
    2 1 5
    

    输出#1

    8
    4
    4
    12
    10
    
首页