#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
using namespace std;
int n, m;
vector<string> mat;
bool vis[4001][4001];
int dist[4001][4001], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool in_range(int i, int j){
if(i >= 0 && j >= 0 && i < n && j < m) return true;
return false;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
mat.resize(n);
for(int i = 0; i < n; i++)
cin>>mat[i];
deque<pii> q;
q.push(mp(0,0));
int ans = 1;
dist[0][0] = vis[0][0] = 1;
while(!q.empty()){
pii at = q.front();
q.pop_front();
ans = max(ans, dist[at.first][at.second]);
for(int dir = 0; dir < 4; dir++){
int nx = at.first + dx[dir], ny = at.second + dy[dir];
if(in_range(nx, ny) && mat[nx][ny] != '.' && !vis[nx][ny]){
vis[nx][ny] = true;
dist[nx][ny] = dist[at.first][at.second] + (mat[at.first][at.second] != mat[nx][ny]);
if(mat[at.first][at.second] != mat[nx][ny]) q.pb(mp(nx,ny));
else q.push_front(mp(nx,ny));
//q.push(mp(-dist[nx][ny], mp(nx,ny)));
}
}
}
cout<<ans<<endl;
}
Compilation message
tracks.cpp: In function 'int main()':
tracks.cpp:28:4: error: 'class std::deque<std::pair<int, int> >' has no member named 'push'
28 | q.push(mp(0,0));
| ^~~~