結果

問題 No.755 Zero-Sum Rectangle
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-25 19:41:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 77,852 KB
最終ジャッジ日時 2023-08-24 01:47:56
合計ジャッジ時間 18,331 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

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

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

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[i][j] - a[i-1][l] - a[k][j-1] + a[i-1][j-1] == 0:
                    cnt[i][j] += 1
                    if l+1 <= m:
                        cnt[i][l+1] -= 1
                    if k+1 <= m:
                        cnt[k+1][j] -= 1
                    if k+1 <= m and l+1 <= m:
                        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