library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub hidehic0/library

:heavy_check_mark: tests/aoj0560.py

Depends on

Code

# 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))

Test cases

Env Name Status Elapsed Memory
Python testcase_00 :heavy_check_mark: AC 24 ms 11 MB
Python testcase_01 :heavy_check_mark: AC 24 ms 11 MB
Python testcase_02 :heavy_check_mark: AC 63 ms 16 MB
Python testcase_03 :heavy_check_mark: AC 402 ms 16 MB
Python testcase_04 :heavy_check_mark: AC 651 ms 16 MB
Python testcase_05 :heavy_check_mark: AC 1369 ms 123 MB
Python testcase_06 :heavy_check_mark: AC 1502 ms 125 MB
Python testcase_07 :heavy_check_mark: AC 1547 ms 126 MB
Python testcase_08 :heavy_check_mark: AC 1598 ms 127 MB
Python testcase_09 :heavy_check_mark: AC 1536 ms 128 MB
Back to top page