Submission #389906

#TimeUsernameProblemLanguageResultExecution timeMemory
389906null_aweTracks in the Snow (BOI13_tracks)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> field(h, vector<int>(w, 0)), rank(h, vector<int>(w, -1));
  for (int i = 0; i < h; ++i) {
    string line;
    cin >> line;
    for (int j = 0; j < w; ++j) field[i][j] = (line[j] == '.' ? -1 : (line[j] == 'R' ? 1 : 2));
  }
  int m = 1;
  rank[0][0] = 1;
  queue<vector<int>> q;
  vector<int> first{0, 0};
  q.push(first);
  while (!q.empty()) {
    vector<int> s = q.front();
    m = max(m, rank[s[0]][s[1]]);
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int x = s[0] + dx[i], y = s[1] + dy[i];
      if (x < 0 || y < 0 || x >= h || y >= w) continue;
      if (rank[x][y] > 0 || field[x][y] < 0) continue;
      vector<int> add{x, y};
      if (field[s[0]][s[1]] == field[x][y]) q.push_front(add);
      else q.push_back(add);
      rank[x][y] = rank[s[0]][s[1]] + (field[s[0]][s[1]] == field[x][y] ? 0 : 1);
    }
  }
  cout << m;
  return 0;
}

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:29:47: error: 'class std::queue<std::vector<int> >' has no member named 'push_front'
   29 |       if (field[s[0]][s[1]] == field[x][y]) q.push_front(add);
      |                                               ^~~~~~~~~~
tracks.cpp:30:14: error: 'class std::queue<std::vector<int> >' has no member named 'push_back'
   30 |       else q.push_back(add);
      |              ^~~~~~~~~