結果
問題 | No.1490 スライムと爆弾 |
ユーザー |
![]() |
提出日時 | 2021-04-23 22:37:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 1,575 bytes |
コンパイル時間 | 3,612 ms |
コンパイル使用メモリ | 195,480 KB |
最終ジャッジ日時 | 2025-01-21 00:13:00 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using ll = long long;using namespace std;ll s[2001][2001];struct P {int t, u, l, r, a;};int main() {ios::sync_with_stdio(false);cin.tie(0);int h, w, n, m;cin >> h >> w >> n >> m;vector<P> p(n);for (int i = 0; i < n; i++) {int t, u, l, r, a;cin >> t >> u >> l >> r >> a;t--; l--;t--; u--; l--; r--;p[i] = { t, u, l, r, a };}for (int i = 0; i < m; i++) {int x, y, b, c;cin >> x >> y >> b >> c;int t = max(x - b - 1, 0);int u = min(x + b, h);int l = max(y - b - 1, 0);int r = min(y + b, w);s[t][l] += c;s[t][r] -= c;s[u][l] -= c;s[u][r] += c;}for (int l = 0; l < 2; l++) {for (int i = 1; i <= h; i++) {for (int j = 0; j <= w; j++) {s[i][j] += s[i - 1][j];}}for (int i = 0; i <= h; i++) {for (int j = 1; j <= w; j++) {s[i][j] += s[i][j - 1];}}//for (int i = 0; i <= h; i++) {// for (int j = 0; j <= w; j++) {// cout << s[i][j] << ' ';// }// cout << '\n';//}//cout << '\n';}int ans = 0;for (auto [t, u, l, r, a] : p) {ll c = s[u][r] - (l < 0 ? 0 : s[u][l]) - (t < 0 ? 0 : s[t][r]) + (l < 0 || t < 0 ? 0 : s[t][l]);//cout << c << ' ' << a << endl;ans += c < a;}cout << ans << endl;return 0;}