#P12561. [UTS 2024] Matrix

    ID: 14128 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>递推倍增单调队列2024UOI(乌克兰)

[UTS 2024] Matrix

题目描述

You are given a matrix of size n×mn \times m consisting of elements ai,ja_{i,j}.

We call a triangle on the matrix of size kk starting at point (x;y)(x;y) a set of points that can be reached from (x;y)(x;y) in no more than kk steps going either up or right.

You are asked to find for each (x;y)(x;y) (kxn,1ymk+1)(k \le x \le n, 1 \le y \le m-k+1) the following values:

  • The maximal value in the triangle of size kk starting at point (x;y)(x;y);
  • The number of occurrences of the maximal value in that triangle.

输入格式

The first line contains three integers nn, mm, and kk (1n,m2000,1kmin(n,m))(1 \le n,m \le 2\,000, 1 \le k \le \min(n,m)) --- dimensions of the matrix and the size of the triangle.

The following nn lines contain mm integers ai,ja_{i,j} (0ai,j106)(0 \le a_{i,j} \le 10^6) --- description of the matrix.

输出格式

Print two matrices of size (nk+1)×(mk+1)(n-k+1)\times(m-k+1).

The first matrix in position (i;j)(i;j) should contain the maximal value of a triangle of size kk starting at (i+k1;j)(i+k-1;j).

The second matrix in position (i;j)(i;j) should contain the number of occurrences of the maximal value in the triangle of size kk starting at (i+k1;j)(i+k-1;j).

4 4 2
1 2 6 14
12 3 13 5
11 4 7 8
10 16 9 15
12 13 13 
12 7 13 
16 16 15 
1 1 1 
1 1 1 
1 1 1 

提示

  • (55 points) n,m20n,m \le 20;
  • (1010 points) n,m100n,m \le 100;
  • (3030 points) ai,j1a_{i,j} \le 1;
  • (3535 points) n,m1000n,m \le 1\,000;
  • (2020 points) no additional restrictions.