結果

問題 No.755 Zero-Sum Rectangle
ユーザー H3PO4H3PO4
提出日時 2021-01-06 09:26:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 730 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 49,748 KB
最終ジャッジ日時 2024-04-24 11:10:58
合計ジャッジ時間 6,971 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 543 ms
49,748 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
evil_1 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import numpy as np

N, M = map(int, input().split())
A = np.zeros((M + 1, M + 1), dtype=np.int64)
A[1:, 1:] = np.array([tuple(map(int, input().split())) for _ in range(M)])
acc = A.cumsum(axis=0).cumsum(axis=1).tolist()

imos = [[0] * (M + 1) for _ in range(M + 1)]
for x1, x2 in itertools.combinations(range(M + 1), 2):
    for y1, y2 in itertools.combinations(range(M + 1), 2):
        if acc[x1][y1] + acc[x2][y2] == acc[x1][y2] + acc[x2][y1]:
            imos[x1][y1] += 1
            imos[x2][y2] += 1
            imos[x1][y2] -= 1
            imos[x2][y1] -= 1

imos = np.array(imos).cumsum(axis=0).cumsum(axis=1)

for _ in range(N):
    x, y = ((int(a) - 1) for a in input().split())
    print(imos[x, y])
0