結果

問題 No.755 Zero-Sum Rectangle
ユーザー kokatsukokatsu
提出日時 2021-11-17 22:04:04
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 205,820 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-04 14:59:37
合計ジャッジ時間 7,896 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 166 ms
4,884 KB
testcase_02 AC 145 ms
4,828 KB
testcase_03 AC 197 ms
6,096 KB
testcase_04 AC 214 ms
4,788 KB
testcase_05 AC 222 ms
4,852 KB
testcase_06 AC 145 ms
4,872 KB
testcase_07 AC 137 ms
4,856 KB
testcase_08 AC 186 ms
4,884 KB
testcase_09 AC 209 ms
5,136 KB
testcase_10 AC 237 ms
5,056 KB
testcase_11 AC 1 ms
4,380 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N, M;
    readf("%d %d\n", N, M);

    auto A = new long[][](M+1, M+1);
    foreach (i; 0 .. M) {
        auto input = readln.chomp.split.to!(long[]);
        A[i+1][1..M+1] = input;
    }

    foreach (i; 0 .. M) {
        A[i+1][] += A[i][];
    }

    foreach (i; 1 .. M+1) {
        foreach (j; 0 .. M) {
            A[i][j+1] += A[i][j];
        }
    }

    foreach (i; 0 .. N) {
        int x, y;
        readf("%d %d\n", x, y);

        long res;
        foreach (xs; 1 .. x+1) {
            foreach (xt; x .. M+1) {
                foreach (ys; 1 .. y+1) {
                    foreach (yt; y .. M+1) {
                        if (A[xt][yt] - A[xs-1][yt] - A[xt][ys-1] + A[xs-1][ys-1] == 0) {
                            ++res;
                        }
                    }
                }
            }
        }

        res.writeln;
    }
}
0