CF1093G.Multidimensional Queries
提高+/省选-
通过率:0%
时间限制:6.00s
内存限制:512MB
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.
给你一个包含 n 个点的数组 a,每个点位于 k 维空间中。定义两个点 ax 和 ay 之间的距离为 i=1∑k∣ax,i−ay,i∣(该距离也称为曼哈顿距离)。
你需要处理 q 个如下两种类型的查询:
- 1 i b1 b2 ... bk —— 将数组 a 的第 i 个元素设置为点 (b1,b2,…,bk);
- 2 l r —— 在下标满足 l≤i,j≤r 的所有点对 ai 和 aj 中,求它们之间最大的距离。
输入格式
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.
第一行包含两个整数 n 和 k(1≤n≤2⋅105,1≤k≤5)—— 分别表示数组 a 的元素个数以及空间的维数。
接下来 n 行,每行包含 k 个整数 ai,1、ai,2、…、ai,k(−106≤ai,j≤106)—— 表示第 i 个点的坐标。
接下来一行包含一个整数 q(1≤q≤2⋅105)—— 表示查询的个数。
随后 q 行,每行描述一个查询。查询分为两类:
- 1 i b1 b2 … bk(1≤i≤n,−106≤bj≤106)—— 将 a 的第 i 个元素更新为点 (b1,b2,…,bk);
- 2 l r(1≤l≤r≤n)—— 求下标满足 l≤i,j≤r 的所有点对 ai 与 aj 之间的最大距离。
保证至少存在一个第二类查询。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?