結果

問題 No.755 Zero-Sum Rectangle
ユーザー t33ft33f
提出日時 2018-12-06 19:50:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 77,220 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-10-12 02:50:17
合計ジャッジ時間 8,200 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,960 KB
testcase_01 AC 17 ms
4,352 KB
testcase_02 AC 207 ms
4,348 KB
testcase_03 AC 346 ms
4,348 KB
testcase_04 AC 395 ms
4,348 KB
testcase_05 AC 457 ms
4,352 KB
testcase_06 AC 407 ms
4,352 KB
testcase_07 AC 427 ms
4,352 KB
testcase_08 AC 387 ms
4,352 KB
testcase_09 AC 509 ms
4,348 KB
testcase_10 AC 488 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <iostream>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    long long a[132][132] = {};
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= m; j++) a[i][j] += a[i][j-1];
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= m; j++) a[i][j] += a[i-1][j];

    while (n--) {
        int x, y; cin >> x >> y;
        long long ans = 0;
        for (int left = 1; left <= y; left++)
            for (int right = y; right <= m; right++) {
                map<long long, int> upper, lower;
                for (int i = 0; i < x; i++)
                    upper[a[i][right] - a[i][left-1]]++;
                for (int i = x; i <= m; i++)
                    ans += upper[a[i][right] - a[i][left-1]];
            }
        cout << ans << endl;
    }
}
0