結果
| 問題 | No.755 Zero-Sum Rectangle |
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2018-12-08 20:36:41 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 1,985 ms / 2,000 ms |
| コード長 | 715 bytes |
| 記録 | |
| コンパイル時間 | 3,341 ms |
| コンパイル使用メモリ | 67,196 KB |
| 実行使用メモリ | 13,760 KB |
| 最終ジャッジ日時 | 2024-07-01 05:46:32 |
| 合計ジャッジ時間 | 24,623 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 TLE * 1 |
ソースコード
import strutils, sequtils
proc main() =
let
nm = stdin.readLine.split.map(parseInt)
(n, m) = (nm[0], nm[1])
a = (0..<m).mapIt(stdin.readLine.split.map(parseInt))
var acc = newSeqWith(m+1, newSeq[int64](m+1))
for i in 1..m:
for j in 1..m:
acc[i][j] = a[i-1][j-1]+acc[i][j-1]+(acc[i-1][j]-acc[i-1][j-1])
for _ in 0..<n:
let
yx = stdin.readLine.split.map(parseInt)
(y, x) = (yx[0], yx[1])
var tot = 0
for sy in 1..m:
for sx in 1..m:
for gy in sy..m:
for gx in sx..m:
if sy<=y and y<=gy and sx<=x and x<=gx:
if acc[gy][gx]-acc[gy][sx-1]-acc[sy-1][gx]+acc[sy-1][sx-1]==0:
tot+=1
echo tot
main()
ikd