結果

問題 No.1490 スライムと爆弾
ユーザー firiexpfiriexp
提出日時 2021-04-23 22:21:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,498 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 96,768 KB
最終ジャッジ日時 2023-09-17 12:29:50
合計ジャッジ時間 1,615 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:26:25: エラー: 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: エラー: ‘std::array<int, 5> <structured bindings>’ has incomplete type
   49 |     for(auto [t, u, l, r, a] : slime){
      |              ^~~~~~~~~~~~~~~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/string:47,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:42,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ostream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/iostream:39,
         次から読み込み:  main.cpp:1:
/usr/local/gcc7/include/c++/12.2.0/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
/usr/local/gcc7/include/c++/12.2.0/bits/stl_iterator.h:1107:11: エラー: cannot increment a pointer to incomplete type ‘std::array<int, 5>’
 1107 |         ++_M_current;
      |           ^~~~~~~~~~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/vector:64,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/queue:61,
         次から読み込み:  main.cpp:5:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::array<int, 5>; _Alloc = std::allocator<std::array<int, 5> >]’:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h:552:47:   required from ‘std::vecto

ソースコード

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