제출 #1153606

#제출 시각아이디문제언어결과실행 시간메모리
1153606vladiliusMaze (JOI23_ho_t3)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int r, c, n, sx, sy, ex, ey; cin>>r>>c>>n>>sx>>sy>>ex>>ey; char a[r + 1][c + 1]; vector<pii> adj[r + 1][c + 1]; set<int> st[r + 1]; for (int i = 1; i <= r; i++){ for (int j = 1; j <= c; j++){ cin>>a[i][j]; if (i > 1) adj[i][j].pb({i - 1, j}); if (j > 1) adj[i][j].pb({i, j - 1}); if (i < r) adj[i][j].pb({i + 1, j}); if (j < c) adj[i][j].pb({i, j + 1}); st[i].insert(j); } } vector<vector<int>> dist(r + 1, vector<int>(c + 1, 1e9)); queue<pii> q, q1; q.push({sx, sy}); dist[sx][sy] = 0; st[sx].erase(sy); auto move = [&](int x, int y){ if (a[x][y] == '.') q1.push({x, y}); for (auto [x1, y1]: adj[x][y]){ if (a[x1][y1] == '.'){ q1.push({x1, y1}); } } while (!q1.empty()){ auto [x1, y1] = q1.front(); q1.pop(); if (dist[x1][y1] == 1e9){ dist[x1][y1] = dist[x][y]; st[x1].erase(y1); q.push({x1, y1}); } for (auto [x2, y2]: adj[x1][y1]){ if (a[x2][y2] == '.' && dist[x2][y2] == 1e9){ q1.push({x2, y2}); } } } }; move(sx, sy); while (!q.empty()){ auto [x, y] = q.front(); q.pop(); if (x == ex && y == ey){ cout<<dist[x][y]<<"\n"; return 0; } int L = y - n, R = y + n; for (int i = max(1, x - n); i <= min(r, x + n); i++){ int L1 = L + (abs(i - x) == n), R1 = R - (abs(i - x) == n); while (true){ auto it = st[i].lower_bound(L1); if (it == st[i].end() || (*it) > R1) break; int y1 = *it; dist[i][y1] = dist[x][y] + 1; q.push({i, y1}); move(i, y1); st[i].erase(it); } } } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In lambda function:
Main.cpp:34:13: sorry, unimplemented: capture of variably-modified type 'char [(r + 1)][(c + 1)]' that is not an N3639 array of runtime bound
   34 |         if (a[x][y] == '.') q1.push({x, y});
      |             ^
Main.cpp:34:13: note: because the array element type 'char [(c + 1)]' has variable size
Main.cpp:35:29: sorry, unimplemented: capture of variably-modified type 'std::vector<std::pair<int, int> > [(r + 1)][(c + 1)]' that is not an N3639 array of runtime bound
   35 |         for (auto [x1, y1]: adj[x][y]){
      |                             ^~~
Main.cpp:35:29: note: because the array element type 'std::vector<std::pair<int, int> > [(c + 1)]' has variable size
Main.cpp:36:17: sorry, unimplemented: capture of variably-modified type 'char [(r + 1)][(c + 1)]' that is not an N3639 array of runtime bound
   36 |             if (a[x1][y1] == '.'){
      |                 ^
Main.cpp:36:17: note: because the array element type 'char [(c + 1)]' has variable size
Main.cpp:37:24: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   37 |                 q1.push({x1, y1});
      |                 ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:47:33: sorry, unimplemented: capture of variably-modified type 'std::vector<std::pair<int, int> > [(r + 1)][(c + 1)]' that is not an N3639 array of runtime bound
   47 |             for (auto [x2, y2]: adj[x1][y1]){
      |                                 ^~~
Main.cpp:47:33: note: because the array element type 'std::vector<std::pair<int, int> > [(c + 1)]' has variable size
Main.cpp:48:21: sorry, unimplemented: capture of variably-modified type 'char [(r + 1)][(c + 1)]' that is not an N3639 array of runtime bound
   48 |                 if (a[x2][y2] == '.' && dist[x2][y2] == 1e9){
      |                     ^
Main.cpp:48:21: note: because the array element type 'char [(c + 1)]' has variable size
Main.cpp:49:28: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   49 |                     q1.push({x2, y2});
      |                     ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~