This documentation is automatically generated by competitive-verifier/competitive-verifier
# competitive-verifier: PROBLEM https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560
from libs.prefix_sum_2d import PrefixSum2D
H, W = map(int, input().split())
K = int(input())
S = [input() for _ in [0] * H]
JS, IS, OS = PrefixSum2D(H, W), PrefixSum2D(H, W), PrefixSum2D(H, W)
for i in range(H):
for k in range(W):
match S[i][k]:
case "J":
JS.add(i, k, 1)
case "O":
OS.add(i, k, 1)
case "I":
IS.add(i, k, 1)
JS.build()
IS.build()
OS.build()
for _ in [0] * K:
ax, ay, bx, by = map(int, input().split())
ax -= 1
ay -= 1
bx -= 1
by -= 1
print(JS.prod(ax, ay, bx, by), OS.prod(ax, ay, bx, by), IS.prod(ax, ay, bx, by))
Env | Name | Status | Elapsed | Memory |
---|---|---|---|---|
Python | testcase_00 |
![]() |
24 ms | 11 MB |
Python | testcase_01 |
![]() |
24 ms | 11 MB |
Python | testcase_02 |
![]() |
63 ms | 16 MB |
Python | testcase_03 |
![]() |
402 ms | 16 MB |
Python | testcase_04 |
![]() |
651 ms | 16 MB |
Python | testcase_05 |
![]() |
1369 ms | 123 MB |
Python | testcase_06 |
![]() |
1502 ms | 125 MB |
Python | testcase_07 |
![]() |
1547 ms | 126 MB |
Python | testcase_08 |
![]() |
1598 ms | 127 MB |
Python | testcase_09 |
![]() |
1536 ms | 128 MB |