답안 #1045805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045805 2024-08-06T07:49:43 Z 우민규(#11015) Cell Automaton (JOI23_cell) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int size = 5000;
const int offset = 2500;

int n, q;

int dist[size][size];
queue<pair<int, pair<int, int>>> qu;
int dist_cnt[2 * size];

void solve() {
    for (int i = 0; i < size; ++i) fill(dist[i], dist[i] + size, INT_MAX);
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        x += offset, y += offset;
        dist[y][x] = 0;
        qu.push({0, {y, x}});
    }
    while (!qu.empty()) {
        auto [d, loc] = qu.front();
        qu.pop();
        auto [y, x] = loc;
        for (auto [yy, xx] : initializer_list<pair<int, int>>{{y-1, x}, {y+1, x}, {y,x-1}, {y,x+1}}) {
            if (yy < 0 || yy >= size || xx < 0 || xx >= size) continue;
            if (dist[yy][xx] != INT_MAX) continue;
            dist[yy][xx] = d + 1;
            qu.push({d + 1, {yy, xx}});
        }
    }
    for (int i = 0; i < size; ++i) for (int j = 0; j < size; ++j) {
        if (dist[i][j] != INT_MAX) {
            dist_cnt[dist[i][j]] += 1;
        }
    }
    while (q--) {
        int t;
        cin >> t;
        cout << dist_cnt[t] << "\n";
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    solve();
}

Compilation message

cell.cpp:9:10: error: reference to 'size' is ambiguous
    9 | int dist[size][size];
      |          ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:9:16: error: reference to 'size' is ambiguous
    9 | int dist[size][size];
      |                ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:11:18: error: reference to 'size' is ambiguous
   11 | int dist_cnt[2 * size];
      |                  ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp: In function 'void solve()':
cell.cpp:14:25: error: reference to 'size' is ambiguous
   14 |     for (int i = 0; i < size; ++i) fill(dist[i], dist[i] + size, INT_MAX);
      |                         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:14:41: error: 'dist' was not declared in this scope
   14 |     for (int i = 0; i < size; ++i) fill(dist[i], dist[i] + size, INT_MAX);
      |                                         ^~~~
cell.cpp:14:60: error: reference to 'size' is ambiguous
   14 |     for (int i = 0; i < size; ++i) fill(dist[i], dist[i] + size, INT_MAX);
      |                                                            ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:20:9: error: 'dist' was not declared in this scope
   20 |         dist[y][x] = 0;
      |         ^~~~
cell.cpp:28:33: error: reference to 'size' is ambiguous
   28 |             if (yy < 0 || yy >= size || xx < 0 || xx >= size) continue;
      |                                 ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:28:57: error: reference to 'size' is ambiguous
   28 |             if (yy < 0 || yy >= size || xx < 0 || xx >= size) continue;
      |                                                         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:29:17: error: 'dist' was not declared in this scope
   29 |             if (dist[yy][xx] != INT_MAX) continue;
      |                 ^~~~
cell.cpp:30:13: error: 'dist' was not declared in this scope
   30 |             dist[yy][xx] = d + 1;
      |             ^~~~
cell.cpp:34:25: error: reference to 'size' is ambiguous
   34 |     for (int i = 0; i < size; ++i) for (int j = 0; j < size; ++j) {
      |                         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:34:56: error: reference to 'size' is ambiguous
   34 |     for (int i = 0; i < size; ++i) for (int j = 0; j < size; ++j) {
      |                                                        ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cell.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
cell.cpp:4:11: note:                 'const int size'
    4 | const int size = 5000;
      |           ^~~~
cell.cpp:35:13: error: 'dist' was not declared in this scope
   35 |         if (dist[i][j] != INT_MAX) {
      |             ^~~~
cell.cpp:36:13: error: 'dist_cnt' was not declared in this scope
   36 |             dist_cnt[dist[i][j]] += 1;
      |             ^~~~~~~~
cell.cpp:42:17: error: 'dist_cnt' was not declared in this scope
   42 |         cout << dist_cnt[t] << "\n";
      |                 ^~~~~~~~
cell.cpp: In function 'int main()':
cell.cpp:48:9: warning: unused variable 't' [-Wunused-variable]
   48 |     int t = 1;
      |         ^