Submission #1093930

#TimeUsernameProblemLanguageResultExecution timeMemory
1093930Trisanu_DasRobots (APIO13_robots)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; struct DJK { int i; int j; int s; long long w; bool operator < (const DJK & o) const{ return w > o.w; } }; int n, m; int di[4] = {-1, 0, 1, 0}, dj[4] = {0, 1, 0, -1}; long long dis[505][505][515]; pair<int, int> des[4][505][505]; char t[505][505]; queue<pair<int, int>> bfs; priority_queue<DJK> djk; bool visit[505][505][515]; pair<int, int> compute(int i, int j, int d) { if(des[d][i][j].first) return des[d][i][j]; int dd = d; if(t[i][j] == 'A') { dd += 3; dd %= 4; } else if(t[i][j] == 'C') { dd += 5; dd %= 4; } int ii = i + di[dd], jj = j + dj[dd]; if(ii < 1 || jj < 1 || ii > n || jj > m || t[ii][jj] == 'x') return des[d][i][j] = {i, j}; return des[d][i][j] = compute(ii, jj, dd); } int main() { int K; scanf(" %d %d %d",&K,&m,&n); for(int i=1 ; i<=n ; i++) scanf(" %s",t[i]+1); for(int i=1 ; i<=n ; i++) for(int j=1 ; j<=m ; j++) { for(int k=1 ; k<(1<<K) ; k++) dis[i][j][k] = 1e9; if(t[i][j] == 'x') continue ; if('1' <= t[i][j] && t[i][j] <= '9') { int s = 1<<(t[i][j]-'0'-1); dis[i][j][s] = 0; djk.push({i, j, s, 0}); } for(int k=0 ; k<4 ; k++) compute(i, j, k); } while(!djk.empty()) { int i = djk.top().i; int j = djk.top().j; int s = djk.top().s; long long w = djk.top().w; djk.pop(); if(visit[i][j][s]) continue ; visit[i][j][s] = true; if(s+1 == (1<<K)) { printf("%d\n",w); return 0; } for(int k=0 ; k<4 ; k++) { int ii = des[k][i][j].first, jj = des[k][i][j].second; for(int it=0 ; it<(1<<K) ; it++) { int ss = it|s; if(dis[ii][jj][it] != 1e9 && dis[ii][jj][ss] > dis[ii][jj][it] + w + 1) { dis[ii][jj][ss] = dis[ii][jj][it] + w + 1; djk.push({ii, jj, ss, dis[ii][jj][ss]}); } } } } printf("-1\n"); return 0; }

Compilation message (stderr)

robots.cpp: In function 'int main()':
robots.cpp:70:6: error: reference to 'visit' is ambiguous
   70 |   if(visit[i][j][s]) continue ;
      |      ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from robots.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
robots.cpp:22:6: note:                 'bool visit [505][505][515]'
   22 | bool visit[505][505][515];
      |      ^~~~~
robots.cpp:71:3: error: reference to 'visit' is ambiguous
   71 |   visit[i][j][s] = true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from robots.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
robots.cpp:22:6: note:                 'bool visit [505][505][515]'
   22 | bool visit[505][505][515];
      |      ^~~~~
robots.cpp:74:13: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   74 |    printf("%d\n",w);
      |            ~^    ~
      |             |    |
      |             int  long long int
      |            %lld
robots.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |  scanf(" %d %d %d",&K,&m,&n);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
robots.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   scanf(" %s",t[i]+1);
      |   ~~~~~^~~~~~~~~~~~~~