結果
| 問題 | No.755 Zero-Sum Rectangle | 
| コンテスト | |
| ユーザー |  けーむ | 
| 提出日時 | 2020-06-30 17:27:09 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,007 ms / 2,000 ms | 
| コード長 | 1,579 bytes | 
| コンパイル時間 | 1,782 ms | 
| コンパイル使用メモリ | 172,324 KB | 
| 実行使用メモリ | 10,624 KB | 
| 最終ジャッジ日時 | 2024-07-23 19:05:50 | 
| 合計ジャッジ時間 | 7,627 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 TLE * 1 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(m, vector<ll>(m));
    rep(i, m) rep(j, m) cin >> a[i][j];
    vector<ll> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    vector<vector<ll>> dp(m + 1, vector<ll>(m + 1, 0));
    rep(i, m) rep(j, m) dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + a[i][j];
    vector<ll> ans(n, 0);
    rep(sx, m) {
        rep(sy, m) {
            reps(gx, sx, m) {
                reps(gy, sy, m) {
                    ll v = dp[gx + 1][gy + 1] - dp[gx + 1][sy] - dp[sx][gy + 1] + dp[sx][sy];
                    if (v == 0) {
                        rep(i, n) {
                            if ((sx <= x[i]) && (gx >= x[i]) && (sy <= y[i]) && (gy >= y[i])) {
                                ans[i]++;
                            }
                        }
                    }
                }
            }
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}
            
            
            
        