|
| 1 | +/* |
| 2 | + * @Author: tkzzzzzz6 |
| 3 | + * @Date: 2026-05-27 08:59:09 |
| 4 | + * @LastEditors: tkzzzzzz6 |
| 5 | + * @LastEditTime: 2026-05-27 10:04:32 |
| 6 | + */ |
| 7 | +#include <iostream> |
| 8 | +#include <vector> |
| 9 | +#include <algorithm> |
| 10 | +#define endl '\n' |
| 11 | +using namespace std; |
| 12 | + |
| 13 | +int main() { |
| 14 | + ios::sync_with_stdio(0); |
| 15 | + cin.tie(0); |
| 16 | + cout.tie(0); |
| 17 | + |
| 18 | + int n, L, r, t; |
| 19 | + cin >> n >> L >> r >> t; |
| 20 | + |
| 21 | + vector<vector<int>> A(n, vector<int>(n)); |
| 22 | + for (int i = 0; i < n; ++i) |
| 23 | + for (int j = 0; j < n; ++j) |
| 24 | + cin >> A[i][j]; |
| 25 | + |
| 26 | + vector<vector<long long>> sum(n, vector<long long>(n)); |
| 27 | + for (int i = 0; i < n; ++i) |
| 28 | + for (int j = 0; j < n; ++j) { |
| 29 | + sum[i][j] += A[i][j]; |
| 30 | + if (i > 0) sum[i][j] += sum[i - 1][j]; |
| 31 | + if (j > 0) sum[i][j] += sum[i][j - 1]; |
| 32 | + if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1]; |
| 33 | + } |
| 34 | + |
| 35 | + auto query = [&](int x1, int y1, int x2, int y2) -> long long { |
| 36 | + long long res = sum[x2][y2]; |
| 37 | + if (x1 > 0) res -= sum[x1 - 1][y2]; |
| 38 | + if (y1 > 0) res -= sum[x2][y1 - 1]; |
| 39 | + if (x1 > 0 && y1 > 0) res += sum[x1 - 1][y1 - 1]; |
| 40 | + return res; |
| 41 | + }; |
| 42 | + |
| 43 | + int ans = 0; |
| 44 | + for (int i = 0; i < n; ++i) { |
| 45 | + for (int j = 0; j < n; ++j) { |
| 46 | + int x1 = max(0, i - r), y1 = max(0, j - r); |
| 47 | + int x2 = min(n - 1, i + r), y2 = min(n - 1, j + r); |
| 48 | + long long s = query(x1, y1, x2, y2); |
| 49 | + int m = (x2 - x1 + 1) * (y2 - y1 + 1); |
| 50 | + if (s <= 1LL * t * m) ans++; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + cout << ans << endl; |
| 55 | + |
| 56 | + return 0; |
| 57 | +} |
0 commit comments