結果

問題 No.755 Zero-Sum Rectangle
ユーザー mkawa2mkawa2
提出日時 2020-05-26 09:14:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 809 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-04-21 04:10:35
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
16,256 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 #

from itertools import accumulate

n,m=map(int,input().split())
bb=[[0]*(m+1)]+[[0]+[b for b in accumulate(map(int,input().split()))] for _ in range(m)]

for j in range(m):
    for i in range(m):
        bb[i+1][j+1]+=bb[i][j+1]

cc=[[0]*(m+1) for _ in range(m+1)]
for si in range(m):
    for sj in range(m):
        for gi in range(si+1,m+1):
            for gj in range(sj+1,m+1):
                if bb[si][sj]+bb[gi][gj]-bb[si][gj]-bb[gi][sj]==0:
                    cc[si][sj]+=1
                    cc[gi][gj]+=1
                    cc[si][gj]-=1
                    cc[gi][sj]-=1

for i in range(m+1):
    for j in range(m):
        cc[i][j+1]+=cc[i][j]
for j in range(m+1):
    for i in range(m):
        cc[i+1][j]+=cc[i][j]

for _ in range(n):
    i,j=map(int,input().split())
    print(cc[i-1][j-1])
0