Submission #943491

#TimeUsernameProblemLanguageResultExecution timeMemory
943491myst6Mecho (IOI09_mecho)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; int di[4] = {1, -1, 0, 0}; int dj[4] = {0, 0, 1, -1}; const int maxn = 800; char grid[maxn][maxn]; int dist[maxn][maxn]; int dist2[maxn][maxn]; int main() { cin.tie(0)->sync_with_stdio(0); int N, S; cin >> N >> S; for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { cin >> grid[i][j]; dist[i][j] = inf; } } queue<int> Q; for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { if (grid[i][j] == 'H') { dist[i][j] = 0; Q.push(i*N+j); } } } while (Q.size()) { int x = Q.front(); Q.pop(); int i = x/N, j = x%N; for (int k=0; k<4; k++) { int i2 = i + di[k]; int j2 = j + dj[k]; if (i2 < 0 || j2 < 0 || i2 >= N || j2 >= N) continue; if (grid[i2][j2] != 'G') continue; if (dist[i2][j2] <= dist[i][j]) continue; dist[i2][j2] = dist[i][j] + 1; Q.push(i2*N+j2); } } pair<int,int> begin, end; for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { if (grid[i][j] == 'M') { begin = {i, j}; } else if (grid[i][j] == 'D') { end = {i, j}; } } } int lo = 0, hi = 1 << 30, ans = -1; while (lo <= hi) { int mid = (lo + hi) / 2; // mid = number of steps the bees have progressed already for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { dist2[i][j] = inf; } } dist2[begin.first][begin.second] = 0; Q.push(begin); while (Q.size()) { auto x = Q.front(); Q.pop(); int i = x/N, j = x%N; for (int k=0; k<4; k++) { int i2 = i + di[k]; int j2 = j + dj[k]; if (i2 < 0 || j2 < 0 || i2 >= N || j2 >= N) continue; if (grid[i2][j2] != 'G' && grid[i2][j2] != 'D') continue; if (dist2[i2][j2] <= dist2[i][j]) continue; int T = mid + (dist2[i][j] + 1) / S; if (dist[i2][j2] <= T) continue; dist2[i2][j2] = dist2[i][j] + 1; Q.push(i2*N+j2); } } if (dist2[end.first][end.second] == inf) { hi = mid - 1; } else { ans = mid; lo = mid + 1; } } cout << ans << "\n"; return 0; }

Compilation message (stderr)

mecho.cpp: In function 'int main()':
mecho.cpp:66:17: error: no matching function for call to 'std::queue<int>::push(std::pair<int, int>&)'
   66 |     Q.push(begin);
      |                 ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from mecho.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::queue<int>::value_type&&' {aka 'int&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~