Submission #985998

#TimeUsernameProblemLanguageResultExecution timeMemory
985998VinhLuuMaze (JOI23_ho_t3)C++17
Compilation error
0 ms0 KiB
//#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> //#define int long long //#define ll long long #define fi first #define se second #define pb push_back #define all(lmao) lmao.begin(), lmao.end() using namespace std; typedef pair<int,int> pii; typedef tuple<int,int,int> tp; const int N = 3e6 + 5; const int oo = 1e9 + 1; const int mod = 1e9 + 7; int block = 316; //const ll oo = 5e18; const int ha[4] = {1, -1, 0, 0}; const int co[4] = {0, 0, 1, -1}; const int tx[4] = {1, 1, -1, -1}; const int ty[4] = {1, -1, -1, 1}; int m, n, k, xt, yt, xs, ys; vector<int> f[N], a[N], ph[N], pc[N]; bool kt(int x,int y){ return x >= 1 && x <= m && y >= 1 && y <= n; } int row(int u,int v){ // cerr << u << " " << v << " t\n"; return (ph[u][v] == v ? v : ph[u][v] = row(u, ph[u][v])); } int col(int u,int v){ // cerr << u << " " << v << " " << pc[u][v] << " w\n"; // if(pc[u][v] == u) return u; return (pc[u][v] == u ? u : pc[u][v] = col(pc[u][v], v)); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> m >> n >> k; cin >> xs >> ys >> xt >> yt; for(int i = 1; i <= m; i ++){ string s; cin >> s; f[i].pb(oo); a[i].pb(0); ph[i].pb(0); pc[i].pb(0); for(int j = 0; j < n; j ++){ f[i].pb(oo); pc[i].pb(0); ph[i].pb(j + 1); if(s[j] == '.') a[i].pb(0); else a[i].pb(1); } f[i].pb(oo); a[i].pb(0); ph[i].pb(0); pc[i].pb(0); } for(int i = 1; i <= n + 1; i ++) pc[0].pb(0); for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ pc[j][i] = j; } } priority_queue<tp, vector<tp>, greater<tp>> q; f[xs][ys] = 0; q.push({val, xs, ys}); int ans = oo; while(!q.empty()){ int val, x, y; tie(val, x, y) = q.top(); // int x = q.front().fi; // int y = q.front().se; // cerr << x << " " << y << " y\n"; q.pop(); if(val > f[x][y]) continue if(x == xt && y == yt) ans = min(ans, f[x][y]); for(int d = 0; d < 4; d ++){ int u = x + ha[d]; int v = y + co[d]; // cerr << u << " " << v << " t\n"; if(!kt(u, v) || f[u][v] <= f[x][y] + a[u][v]) continue; f[u][v] = f[x][y] + a[u][v]; q.push({u, v}); if(ph[u][v]){ ph[u][v]--; ph[u][v] = row(u, ph[u][v]); } if(pc[u][v]){ pc[u][v]--; pc[u][v] = col(pc[u][v], v); } } int l = max(1, x - k + 1), r = min(m, x + k - 1), a = max(1, y - k + 1), b = min(n, y + k - 1); if(xt >= l && xt <= r && yt >= a && yt <= b) ans = min(ans, f[x][y] + 1); // for(int d = 0; d < 4; d ++){ // int u = x + d * (k - 1); u = max(u, 1), u = min(u, m); // int v = y + d * (k - 1); v = max(v, 1), v = min(v, n); // if(f[u][v] > f[x][y] + 1){ // q.push({u, v}); // f[u][v] = f[x][y] + 1; // ph[u][v] = le[u][v]; // ph[u][v] = row(u, ph[u][v]); // pc[u][v] = up[u][v]; // pc[u][v] = col(pc[u][v], v); // } // } // cerr << " done\n"; if(l - 1 >= 1){ int lx = l - 1, pos = b; while(ph[lx][pos] >= a){ int g = ph[lx][pos]; if(f[lx][g] > f[x][y] + 1) f[lx][g] = f[x][y] + 1, q.push({lx, g}); if(!ph[lx][pos]) break; ph[lx][pos]--; ph[lx][pos] = row(lx, ph[lx][pos]); } } if(r + 1 <= m){ int lx = r + 1, pos = b; while(ph[lx][pos] >= a){ int g = ph[lx][pos]; if(f[lx][g] > f[x][y] + 1) f[lx][g] = f[x][y] + 1, q.push({lx, g}); if(!ph[lx][pos]) break; ph[lx][pos]--; ph[lx][pos] = row(lx, ph[lx][pos]); } } if(a - 1 >= 1){ int pos = r, ly = a - 1; while(pc[pos][ly] >= l){ int g = pc[pos][ly]; if(f[g][ly] > f[x][y] + 1) f[g][ly] = f[x][y] + 1, q.push({g, ly}); if(!pc[g][ly]) break; pc[g][ly]--; pc[g][ly] = col(pc[g][ly], ly); } } if(b + 1 <= n){ int pos = r, ly = b + 1; while(pc[pos][ly] >= l){ int g = pc[pos][ly]; if(f[g][ly] > f[x][y] + 1) f[g][ly] = f[x][y] + 1, q.push({g, ly}); if(!pc[g][ly]) break; pc[g][ly]--; pc[g][ly] = col(pc[g][ly], ly); } } } cout << min(ans, f[xt][yt]); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:82:13: error: 'val' was not declared in this scope
   82 |     q.push({val, xs, ys});
      |             ^~~
Main.cpp:82:25: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
   82 |     q.push({val, xs, ys});
      |                         ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:90:35: error: expected ';' before 'if'
   90 |         if(val > f[x][y]) continue
      |                                   ^
      |                                   ;
   91 |         if(x == xt && y == yt) ans = min(ans, f[x][y]);
      |         ~~                         
Main.cpp:100:26: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
  100 |             q.push({u, v});
      |                          ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:129:82: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
  129 |                 if(f[lx][g] > f[x][y] + 1) f[lx][g] = f[x][y] + 1, q.push({lx, g});
      |                                                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:139:82: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
  139 |                 if(f[lx][g] > f[x][y] + 1) f[lx][g] = f[x][y] + 1, q.push({lx, g});
      |                                                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:149:82: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
  149 |                 if(f[g][ly] > f[x][y] + 1) f[g][ly] = f[x][y] + 1, q.push({g, ly});
      |                                                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:160:82: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
  160 |                 if(f[g][ly] > f[x][y] + 1) f[g][ly] = f[x][y] + 1, q.push({g, ly});
      |                                                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:3:
/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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>&'}
  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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen(task ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen(task ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~