結果

問題 No.755 Zero-Sum Rectangle
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-25 19:47:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 868 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 16,904 KB
最終ジャッジ日時 2023-08-24 01:48:55
合計ジャッジ時間 3,890 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

n,m=map(int,input().split())

a=[[0]*(m+2)]
for i in  range(m):
    a.append([0]+list(map(int,input().split()))+[0])
a.append([0]*(m+2))

cnt=[[0]*(m+2) for i in range(m+2)]

for i in range(1,len(a)):
    for j in range(1,len(a[i])):
        a[i][j] += a[i-1][j] + a[i][j-1] - a[i-1][j-1]
    

for i in range(1,m+1):
    for j in range(1,m+1):
        for k in range(i,m+1):
            for l in range(j,m+1):
                if  a[k][l] - a[i-1][l] - a[k][j-1] + a[i-1][j-1] == 0:
                    cnt[i][j] += 1
                    cnt[i][l+1] -= 1
                    cnt[k+1][j] -= 1
                    cnt[k+1][l+1] += 1

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

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

for i in range(n):
    x,y=map(int,input().split())
    print(cnt[x][y])
0