Submission #654967

#TimeUsernameProblemLanguageResultExecution timeMemory
654967KiriLL1caPortal (COCI17_portal)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define fr first #define sc second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pw(x) (1ll << x) #define sz(x) (int)((x).size()) #define pb push_back #define endl '\n' #define mp make_pair #define vec vector using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef unsigned long long ull; typedef unsigned int uint; template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> using oset = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; inline void solve () { int n, m; cin >> n >> m; pii s, f; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; if (a[i][j] == 'C') s = {i, j}; if (a[i][j] == 'F') f = {i, j}; d[i][j] = inf; } } for (int i = 0; i < n; ++i) { int lst = -1; for (int j = 0; j < m; ++j) { if (a[i][j] == '#') lst = j; go[i][j][0] = {i, lst + 1}; } lst = m; for (int j = m - 1; j >= 0; --j) { if (a[i][j] == '#') lst = j; go[i][j][1] = {i, lst - 1}; } } for (int j = 0; j < m; ++j) { int lst = -1; for (int i = 0; i < n; ++i) { if (a[i][j] == '#') lst = i; go[i][j][2] = {lst + 1, j}; } lst = n; for (int i = n - 1; i >= 0; --i) { if (a[i][j] == '#') lst = i; go[i][j][3] = {lst - 1, j}; } } priority_queue <array <int, 3>, vector <array <int, 3>>, greater <array <int, 3>>> pq; d[s.fr][s.sc] = 0; pq.push({0, s.fr, s.sc}); function <bool(int, int)> valid = [&] (int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }; function <int(int, int, int, int)> dist = [&] (int x, int y, int xx, int yy) { return abs(x - xx) + abs(y - yy); }; while (sz(pq)) { auto [dis, x, y] = pq.top(); pq.pop(); if (dis > d[x][y]) continue; /// little step for (int i = 0; i < 4; ++i) { int nx = x + dx[i], ny = y + dy[i]; if (valid(nx, ny) && a[nx][ny] != '#' && umin(d[nx][ny], d[x][y] + 1)) pq.push({d[nx][ny], nx, ny}); } /// big step for (int port1 = 0; port1 < 4; ++port1) { for (int port2 = 0; port2 < 4; ++port2) { if (port1 == port2) continue; auto [qx, qy] = go[x][y][port1]; auto [wx, wy] = go[x][y][port2]; if (umin(d[wx][wy], d[x][y] + dist(x, y, qx, qy) + 1)) pq.push({d[wx][wy], wx, wy}); } } } if (d[f.fr][f.sc] == inf) cout << "nemoguce"; else cout << d[f.fr][f.sc]; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t = 1; // cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

portal.cpp: In function 'void solve()':
portal.cpp:35:32: error: 'a' was not declared in this scope
   35 |                         cin >> a[i][j];
      |                                ^
portal.cpp:38:25: error: 'd' was not declared in this scope
   38 |                         d[i][j] = inf;
      |                         ^
portal.cpp:38:35: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   38 |                         d[i][j] = inf;
      |                                   ^~~
      |                                   ynf
portal.cpp:45:29: error: 'a' was not declared in this scope
   45 |                         if (a[i][j] == '#') lst = j;
      |                             ^
portal.cpp:46:25: error: 'go' was not declared in this scope
   46 |                         go[i][j][0] = {i, lst + 1};
      |                         ^~
portal.cpp:51:29: error: 'a' was not declared in this scope
   51 |                         if (a[i][j] == '#') lst = j;
      |                             ^
portal.cpp:52:25: error: 'go' was not declared in this scope
   52 |                         go[i][j][1] = {i, lst - 1};
      |                         ^~
portal.cpp:58:29: error: 'a' was not declared in this scope
   58 |                         if (a[i][j] == '#') lst = i;
      |                             ^
portal.cpp:59:25: error: 'go' was not declared in this scope
   59 |                         go[i][j][2] = {lst + 1, j};
      |                         ^~
portal.cpp:64:29: error: 'a' was not declared in this scope
   64 |                         if (a[i][j] == '#') lst = i;
      |                             ^
portal.cpp:65:25: error: 'go' was not declared in this scope
   65 |                         go[i][j][3] = {lst - 1, j};
      |                         ^~
portal.cpp:70:9: error: 'd' was not declared in this scope
   70 |         d[s.fr][s.sc] = 0; pq.push({0, s.fr, s.sc});
      |         ^
portal.cpp:76:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   76 |                 auto [dis, x, y] = pq.top(); pq.pop();
      |                      ^
portal.cpp:80:38: error: 'dx' was not declared in this scope; did you mean 'nx'?
   80 |                         int nx = x + dx[i], ny = y + dy[i];
      |                                      ^~
      |                                      nx
portal.cpp:81:39: error: 'ny' was not declared in this scope; did you mean 'nx'?
   81 |                         if (valid(nx, ny) && a[nx][ny] != '#' && umin(d[nx][ny], d[x][y] + 1)) pq.push({d[nx][ny], nx, ny});
      |                                       ^~
      |                                       nx
portal.cpp:81:46: error: 'a' was not declared in this scope
   81 |                         if (valid(nx, ny) && a[nx][ny] != '#' && umin(d[nx][ny], d[x][y] + 1)) pq.push({d[nx][ny], nx, ny});
      |                                              ^
portal.cpp:81:123: error: no matching function for call to 'std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3> >, std::greater<std::array<int, 3> > >::push(<brace-enclosed initializer list>)'
   81 |                         if (valid(nx, ny) && a[nx][ny] != '#' && umin(d[nx][ny], d[x][y] + 1)) pq.push({d[nx][ny], nx, ny});
      |                                                                                                                           ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from portal.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3> >; _Compare = std::greater<std::array<int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<int, 3>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<int, 3>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3> >; _Compare = std::greater<std::array<int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<int, 3>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3> >, std::greater<std::array<int, 3> > >::value_type&&' {aka 'std::array<int, 3>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
portal.cpp:88:38: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   88 |                                 auto [qx, qy] = go[x][y][port1];
      |                                      ^
portal.cpp:88:49: error: 'go' was not declared in this scope
   88 |                                 auto [qx, qy] = go[x][y][port1];
      |                                                 ^~
portal.cpp:89:38: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   89 |                                 auto [wx, wy] = go[x][y][port2];
      |                                      ^
portal.cpp:90:115: error: no matching function for call to 'std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3> >, std::greater<std::array<int, 3> > >::push(<brace-enclosed initializer list>)'
   90 |                                 if (umin(d[wx][wy], d[x][y] + dist(x, y, qx, qy) + 1)) pq.push({d[wx][wy], wx, wy});
      |                                                                                                                   ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from portal.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3> >; _Compare = std::greater<std::array<int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<int, 3>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<int, 3>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3> >; _Compare = std::greater<std::array<int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<int, 3>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3> >, std::greater<std::array<int, 3> > >::value_type&&' {aka 'std::array<int, 3>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
portal.cpp:94:30: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   94 |         if (d[f.fr][f.sc] == inf) cout << "nemoguce";
      |                              ^~~
      |                              ynf