Two SigmaOA #3
Replacing Val
估计简单可在线判题
考点(AI 标注)网格搜索
Change the start cell, and every position connected to it through up/down/left/right cells with the same original value, to the given value; cells that touch only diagonally are not connected.
输入格式
The first line contains the number of rows r, the number of columns c, the start row and column, and the replacement value, followed by r lines of the matrix. The original constraints are Unknown; this site specifies 1≤r,c≤1000, matrix and replacement values in −10^9..10^9, and a valid 0-based start. It does not pretend that the bounds added by the catalog are the original bounds.
输出格式
Output the replaced matrix as r lines of c integers each, without repeating the dimensions.
样例 1
输入:
2 3 1 1 2
0 1 0
1 1 0
输出:
0 2 0
2 2 0
样例 2
输入:
2 2 0 0 3
1 0
0 1
输出:
3 0
0 1
样例 3
输入:
1 1 0 0 -1
-1
输出:
-1
样例说明
The outputs of the three public examples are, in order: 0 2 0 / 2 2 0; 3 0 / 0 1; -1. They have been checked by independent enumeration or direct simulation.