結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー | AEn |
提出日時 | 2022-08-30 16:44:25 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,747 bytes |
コンパイル時間 | 1,121 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,352 KB |
最終ジャッジ日時 | 2024-11-07 11:02:41 |
合計ジャッジ時間 | 17,305 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,608 KB |
testcase_01 | TLE | - |
testcase_02 | AC | 1,330 ms
76,968 KB |
testcase_03 | AC | 1,271 ms
77,092 KB |
testcase_04 | AC | 1,241 ms
77,096 KB |
testcase_05 | AC | 1,223 ms
76,976 KB |
testcase_06 | AC | 1,234 ms
77,236 KB |
testcase_07 | AC | 1,224 ms
76,760 KB |
testcase_08 | AC | 1,214 ms
77,352 KB |
testcase_09 | AC | 1,206 ms
76,952 KB |
testcase_10 | AC | 1,216 ms
77,084 KB |
testcase_11 | AC | 49 ms
63,140 KB |
evil_1 | AC | 1,351 ms
78,284 KB |
ソースコード
from itertools import accumulate N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(M)] ac = [[0]*(M+1) for _ in range(M+1)] for i in range(M): for j in range(M): ac[i][j] += A[i][j] ac[-1][-1] += A[i][j] ac[-1][j] -= A[i][j] ac[i][-1] -= A[i][j] for i in range(M+1): for j in range(1, M+1): ac[i][j] += ac[i][j-1] for i in range(1, M+1): for j in range(M+1): ac[i][j] += ac[i-1][j] res = [[0]*(M+1) for _ in range(M+1)] for i in range(M): for j in range(M): num = A[i][j] for x in range(i, M): for y in range(j, M): if i==0 and j==0 and ac[x][y]==0: res[i][j] += 1 res[x+1][y+1] += 1 res[i][y+1] -= 1 res[x+1][j] -= 1 elif i==0 and ac[x][y]-ac[x][j-1]==0: res[i][j] += 1 res[x+1][y+1] += 1 res[i][y+1] -= 1 res[x+1][j] -= 1 elif j==0 and ac[x][y]-ac[i-1][y]==0: res[i][j] += 1 res[x+1][y+1] += 1 res[i][y+1] -= 1 res[x+1][j] -= 1 else: if ac[x][y]-ac[i-1][y]-ac[x][j-1]+ac[i-1][j-1]==0: res[i][j] += 1 res[x+1][y+1] += 1 res[i][y+1] -= 1 res[x+1][j] -= 1 for i in range(M+1): for j in range(1, M+1): res[i][j] += res[i][j-1] for i in range(1, M+1): for j in range(M+1): res[i][j] += res[i-1][j] for i in range(N): x, y = map(int,input().split()) print(res[x-1][y-1])