結果

問題 No.755 Zero-Sum Rectangle
ユーザー rogi52rogi52
提出日時 2022-10-12 23:48:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 991 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 204,612 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 18:42:53
合計ジャッジ時間 5,405 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
evil_1 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,M; cin >> N >> M;
    vector<vector<ll>> A(M, vector<ll>(M));
    rep(i,M)rep(j,M) cin >> A[i + 1][j + 1];
    rep(i,M+1)rep(j,M) A[i][j + 1] += A[i][j];
    rep(i,M)rep(j,M+1) A[i + 1][j] += A[i][j];

    vector<vector<ll>> imos(M + 1, vector<ll>(M + 1, 0));
    rep(x,M)rep(y,M) {
        for(int i = x + 1; i <= M; i++) for(int j = y + 1; j <= M; j++) {
            ll SUM = A[i][j] - A[x][j] - A[i][y] + A[x][y];
            if(SUM == 0LL) {
                imos[x][y]++;
                imos[x][j]--;
                imos[i][y]--;
                imos[i][j]++;
            }
        }
    }

    rep(i,M+1)rep(j,M) imos[i][j + 1] += imos[i][j];
    rep(i,M)rep(j,M+1) imos[i + 1][j] += imos[i][j];

    rep(i,N) {
        int x,y; cin >> x >> y; x--; y--;
        cout << imos[x][y] << "\n";
    }
}
0