CF1093G.Multidimensional Queries
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a of n points in k -dimensional space. Let the distance between two points ax and ay be i=1∑k∣ax,i−ay,i∣ (it is also known as Manhattan distance).
You have to process q queries of the following two types:
- 1 i b1 b2 ... bk — set i -th element of a to the point (b1,b2,…,bk) ;
- 2 l r — find the maximum distance between two points ai and aj , where l≤i,j≤r .
输入格式
The first line contains two numbers n and k ( 1≤n≤2⋅105 , 1≤k≤5 ) — the number of elements in a and the number of dimensions of the space, respectively.
Then n lines follow, each containing k integers ai,1 , ai,2 , ..., ai,k ( −106≤ai,j≤106 ) — the coordinates of i -th point.
The next line contains one integer q ( 1≤q≤2⋅105 ) — the number of queries.
Then q lines follow, each denoting a query. There are two types of queries:
- 1 i b1 b2 ... bk ( 1≤i≤n , −106≤bj≤106 ) — set i -th element of a to the point (b1,b2,…,bk) ;
- 2 l r ( 1≤l≤r≤n ) — find the maximum distance between two points ai and aj , where l≤i,j≤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