結果

問題 No.1490 スライムと爆弾
コンテスト
ユーザー firiexp
提出日時 2021-04-23 22:21:13
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,498 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 515 ms
コンパイル使用メモリ 106,644 KB
最終ジャッジ日時 2026-06-19 22:57:33
合計ジャッジ時間 2,434 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:25: error: range-based 'for' expression of type 'std::array<int, 5>' has incomplete type
   26 |         for (auto &&j : i) scanf("%d", &j);
      |                         ^
main.cpp:49:14: error: deduced type 'std::array<int, 5>' for '<structured bindings>' is incomplete
   49 |     for(auto [t, u, l, r, a] : slime){
      |              ^~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:64,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:53,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<int, 5>'
   99 |     struct array;
      |            ^~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:50:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator.h: In instantiation of 'constexpr __gnu_cxx::__normal_iterator<_Iterator, _Container>& __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator++() [with _Iterator = std::array<int, 5>*; _Container = std::vector<std::array<int, 5> >]':
main.cpp:25:21:   required from here
   25 |     for (auto &&i : slime)
      |                     ^~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/i

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int h, w, n, m;
    cin >> h >> w >> n >> m;
    h++; w++;
    vector<vector<ll>> v(h+1, vector<ll>(w+1, 0));
    vector<array<int, 5>> slime(n);
    for (auto &&i : slime)
        for (auto &&j : i) scanf("%d", &j);
    for (int i = 0; i < m; ++i) {
        int x, y, b, c;
        scanf("%d %d %d %d", &x, &y, &b, &c);
        int A = max(0, x-b), B = min(h, x+b+1), C = max(0, y-b), D = min(w, y+b+1);
        v[A][C] += c; v[B][C] -= c; v[A][D] -= c; v[B][D] += c;
    }
    for (int i = 0; i <= h; ++i) {
        for (int j = 0; j <= w; ++j) {
            if(i) v[i][j] += v[i-1][j];
            if(j) v[i][j] += v[i][j-1];
            if(i && j) v[i][j] -= v[i-1][j-1];
        }
    }

    for (int i = 0; i <= h; ++i) {
        for (int j = 0; j <= w; ++j) {
            if(i) v[i][j] += v[i-1][j];
            if(j) v[i][j] += v[i][j-1];
            if(i && j) v[i][j] -= v[i-1][j-1];
        }
    }
    int ans = 0;
    for(auto [t, u, l, r, a] : slime){
        t--; l--;
        ll val = v[t][l]-v[t][r]-v[u][l]+v[u][r];
        if(val < a) ans++;
    }
    cout << ans << "\n";
    return 0;
}
0