結果
| 問題 | No.755 Zero-Sum Rectangle |
| コンテスト | |
| ユーザー |
htkb
|
| 提出日時 | 2018-12-14 13:01:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 863 bytes |
| 記録 | |
| コンパイル時間 | 206 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 18,336 KB |
| 最終ジャッジ日時 | 2024-09-25 05:00:31 |
| 合計ジャッジ時間 | 3,586 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 11 |
ソースコード
import sys
from itertools import accumulate, product
N, M = map(int, input().split())
a = [[0]*(M+1)]
for _ in [0]*M:
a.append([0]+[a[-1][i]+n for i, n in enumerate(accumulate(map(int, input().split())), start=1)])
result = [[0]*(M+2) for _ in [0]*(M+2)]
for from_x, from_y in product(range(1, M+1), repeat=2):
for to_x, to_y in product(range(from_x, M+1), range(from_y, M+1)):
if a[to_y][to_x] - a[from_y-1][to_x] - a[to_y][from_x-1] + a[from_y-1][from_x-1] == 0:
result[from_y][from_x] += 1
result[from_y][to_x+1] -= 1
result[to_y+1][from_x] -= 1
result[to_y+1][to_x+1] += 1
for y, row in enumerate(result[1:], start=1):
for x, v in enumerate(accumulate(row)):
result[y][x] = v + result[y-1][x]
print(*[result[x][y] for l in sys.stdin for x, y in (map(int, l.split()),)], sep="\n")
htkb