結果

問題 No.755 Zero-Sum Rectangle
ユーザー face4face4
提出日時 2018-12-04 22:59:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,146 ms / 2,000 ms
コード長 1,121 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 66,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 19:02:53
合計ジャッジ時間 6,838 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1,146 ms
4,376 KB
testcase_02 AC 184 ms
4,380 KB
testcase_03 AC 158 ms
4,380 KB
testcase_04 AC 140 ms
4,380 KB
testcase_05 AC 129 ms
4,376 KB
testcase_06 AC 123 ms
4,380 KB
testcase_07 AC 121 ms
4,376 KB
testcase_08 AC 121 ms
4,376 KB
testcase_09 AC 123 ms
4,376 KB
testcase_10 AC 124 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;

    ll mat[131][131] = {};

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= m; j++){
            cin >> mat[i][j];
        }
    }

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= m; j++){
            mat[i][j] += mat[i-1][j] + mat[i][j-1] - mat[i-1][j-1];
        }
    }

    int x[n], y[n];
    for(int i = 0; i < n; i++)  cin >> x[i] >> y[i];
    int ans[10] = {};

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= m; j++){
            for(int ni = i; ni <= m; ni++){
                for(int nj = j; nj <= m; nj++){
                    ll tmp = mat[ni][nj] + mat[i-1][j-1] - mat[i-1][nj] - mat[ni][j-1];
                    if(tmp != 0)    continue;
                    for(int k = 0; k < n; k++){
                        if(inRange(x[k], i, ni) && inRange(y[k], j, nj))    ans[k]++;
                    }
                }
            }
        }
    }

    for(int i = 0; i < n; i++)  cout << ans[i] << endl;

    return 0;
}
0