結果

問題 No.755 Zero-Sum Rectangle
ユーザー mkawa2mkawa2
提出日時 2020-05-26 09:03:41
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,105 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 86,476 KB
実行使用メモリ 79,764 KB
最終ジャッジ日時 2023-08-03 04:46:58
合計ジャッジ時間 3,345 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

import sys

def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())

def main():
    n,m=MI()
    bb=[0]*(m+1)+[[0]+LI() for _ in range(m)]

    for i in range(m):
        for j in range(m):
            bb[i+1][j+1]+=bb[i+1][j]
    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=MI1()
        print(cc[i][j])

main()
0