結果

問題 No.755 Zero-Sum Rectangle
ユーザー Siqing HouSiqing Hou
提出日時 2018-12-25 17:00:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 83,684 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 22:33:49
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 100 ms
6,548 KB
testcase_02 AC 80 ms
6,548 KB
testcase_03 AC 107 ms
6,548 KB
testcase_04 AC 122 ms
6,548 KB
testcase_05 AC 134 ms
6,548 KB
testcase_06 AC 87 ms
6,548 KB
testcase_07 AC 82 ms
6,548 KB
testcase_08 AC 111 ms
6,548 KB
testcase_09 AC 126 ms
6,548 KB
testcase_10 AC 145 ms
6,548 KB
testcase_11 WA -
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * YukiCoder755.cpp
 *
 *  Created on: Dec 25, 2018
 *      Author: Hou
 */


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

int N, M;
long long mat[131][131];
long long sum[131][131];

int main(){
    cin >> N>> M;
    for (int i=1; i<=M; i++)
        for (int j=1; j<=M; j++)
            cin >> mat[i][j];
    sum[0][0] = 0;
    for (int i=1; i<=M; i++){
        sum[i][0] = 0;
        for (int j=1; j<=M; j++)
            sum[i][j] = sum[i][j-1] + mat[i][j];
    }

    for (int j=1; j<=M; j++){
        sum[0][j] = 0;
        for (int i=0; i<=M; i++)
            sum[i][j] = sum[i-1][j] + sum[i][j];
    }

    for (int k=0; k<N; k++){
        int x, y;
        cin >> x>>y;
        int ans = 0;
        for (int x1=1; x1<=x; x1++)
            for (int y1=1; y1<=y; y1++){
                int s1 = sum[x1-1][y1-1];
                for (int x2=x;x2<=M;x2++){
                    int s2 = sum[x2][y1-1];
                    for (int y2=y;y2<=M;y2++){
                        int s3 = sum[x1-1][y2];
                        int s4 = sum[x2][y2];
                        if (s4-s3-s2+s1 == 0)
                            ans++;
                    }
                }
            }
        cout <<ans <<endl;
    }

	return 0;
}
0