当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3467:Cross Counting

题目描述

Given a N × M grid with different colors on each cell, your task is to calculate the total amount of crosses of a specific color. We say there exists a cross of size k centered at the cell (x,y) iff all cells lying in the x-th row or the y-th column and within a distance of k from (x,y) share the same color. Note that if two crosses have the same center but different sizes we consider they are distinct. Unfortunately, the color of each cell may varies by time and you have to respond to all the queries.

输入解释

There are four integers, N, M, C, Q, in the first line. (1 ≤ N, M, C ≤ 100, 1 ≤ Q ≤ 10000)
The next N lines each contains M integers between 1 and C which describe the color of cells.
The following Q lines each has either the form "C i j k" indicating to change the color of cell (i, j) into k, or the form "Q c" indicating to query the total amount of crosses of color c. (1 ≤ iN, 1 ≤ jM, 1 ≤ k, cC)

输出解释

Output the answer to each query.

输入样例
5 5 3 6
1 3 2 3 1
3 3 2 3 3
2 2 2 2 2
3 3 2 3 3
1 3 2 3 1
Q 1
Q 2
Q 3
C 2 3 3
C 3 2 3
Q 3
输出样例
0
2
0
1

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3467

最后修改于 2020-10-29T07:02:18+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 131072