結果

問題 No.1490 スライムと爆弾
ユーザー firiexpfiriexp
提出日時 2021-04-23 22:21:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,498 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 98,792 KB
最終ジャッジ日時 2024-04-27 03:45:45
合計ジャッジ時間 1,865 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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: 'std::array<int, 5> <structured bindings>' has incomplete type
   49 |     for(auto [t, u, l, r, a] : slime){
      |              ^~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:47,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_iterator.h: In instantiation of '__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
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_iterator.h:1107:11: error: cannot increment a pointer to incomplete type 'std::array<int, 5>'
 1107 |         ++_M_current;
      |           ^~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/queue:61,
                 from main.cpp:5:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::array<

ソースコード

diff #

#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