제출 #1340685

#제출 시각아이디문제언어결과실행 시간메모리
1340685alorivaldoTracks in the Snow (BOI13_tracks)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

#define br '\n'

typedef array<int,2> ii;

const int mxn = 4e3+3;
char g[mxn][mxn];

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int n,m;
char start;

bool place(int x, int y)
{
  return (x >= 0 && y >= 0 && x < n && y < m && g[x][y] == start);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n>>m;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      cin>>g[i][j];
    }
  }

  start = g[0][0];
  bool two,three; two = three = false;
  
  queue<ii> q;
  q.push({0,0});
  
  while(!q.empty())
  {
    auto [xo,yo] = q.front(); q.pop();
    g[xo][yo] = 'x';
    for (int i = 0; i < 4; i++){
      int x = xo+dx[i];
      int y = yo+dy[i];
      if ((g[x][y] == 'R' || g[x][y] == 'F') && g[x][y] != start){two = true;}
      if (place(x,y))
      {
        g[x][y] = 'x';
        q.push({x,y});
      }
      
    }
  }


  // varrida pra ver se tem 3
  for (int i = 0; i < n; i++){
    for (int j = 0; j< m; j++){
      if (g[i][j] == start){
        three = true;
      }
    }
  }

  // for (int i = 0; i < n; i++){
  //   for (int j = 0; j< m; j++){
  //     cout << g[i][j];
  //   } cout << br;
  // }


  if (three) cout << 3 << br;
  else if (two) cout << 2 << br;
  else cout << 1 << br;

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'int main()':
tracks.cpp:41:3: error: 'queue' was not declared in this scope
   41 |   queue<ii> q;
      |   ^~~~~
tracks.cpp:5:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    4 | #include <array>
  +++ |+#include <queue>
    5 | 
tracks.cpp:41:11: error: expected primary-expression before '>' token
   41 |   queue<ii> q;
      |           ^
tracks.cpp:41:13: error: 'q' was not declared in this scope
   41 |   queue<ii> q;
      |             ^