結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー | lllllll88938494 |
提出日時 | 2022-09-25 20:13:35 |
言語 | PyPy3 (7.3.13) |
結果 |
TLE
|
実行時間 | - |
コード長 | 865 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 86,920 KB |
実行使用メモリ | 77,580 KB |
最終ジャッジ日時 | 2023-08-24 01:50:02 |
合計ジャッジ時間 | 16,306 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,472 KB |
testcase_01 | TLE | - |
testcase_02 | AC | 1,336 ms
77,464 KB |
testcase_03 | AC | 1,281 ms
77,496 KB |
testcase_04 | AC | 1,264 ms
77,392 KB |
testcase_05 | AC | 1,243 ms
77,316 KB |
testcase_06 | AC | 1,253 ms
77,556 KB |
testcase_07 | AC | 1,258 ms
77,348 KB |
testcase_08 | AC | 1,230 ms
77,228 KB |
testcase_09 | AC | 1,258 ms
76,424 KB |
testcase_10 | AC | 1,235 ms
77,580 KB |
testcase_11 | AC | 77 ms
76,216 KB |
evil_1 | AC | 1,346 ms
78,028 KB |
ソースコード
from itertools import accumulate n,m=map(int,input().split()) a=[[0]*(m+2)] + [[0]+[i for i in accumulate(map(int,input().split()))]+[0] for i in range(m)] + [[0]*(m+2)] cnt=[[0]*(m+2) for i in range(m+2)] for i in range(1,m+1): for j in range(1,m+1): a[i][j] += a[i-1][j] 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 _ in range(n): x,y=map(int,input().split()) print(cnt[x][y])