Submission #1053687

# Submission time Handle Problem Language Result Execution time Memory
1053687 2024-08-11T15:34:48 Z vjudge1 Tracks in the Snow (BOI13_tracks) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()

bool vis[4010][4010];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n,m;cin>>n>>m;
	string s[n];
	for(int i=0;i<n;i++) cin>>s[i];

	priority_queue<pair<int,pii>> pq;
	pq.push({0,{0,0}});
	vis[0][0]=1;
	int ans=0;
	while(!pq.empty())
	{
		int x=pq.top().se.fi,y=pq.top().se.se,v=-pq.top().fi;
		pq.pop();
		ans=max(ans,v);
		if(x-1>=0 && !vis[x-1][y] && s[x-1][y]!='.')
		{
			vis[x-1][y]=1;
			pq.push({-(v+(s[x][y]!=s[x-1][y])),{x-1,y}});
		}
		if(y-1>=0 && !vis[x][y-1] && s[x][y-1]!='.')
		{
			vis[x][y-1]=1;
			pq.push({-(v+(s[x][y]!=s[x][y-1])),{x,y-1}});
		}
		if(x+1<n && !vis[x+1][y] && s[x+1][y]!='.')
		{
			vis[x+1][y]=1;
			pq.push({-(v+(s[x][y]!=s[x+1][y])),{x+1,y}});
		}
		if(y+1<M && !vis[x][y+1] && s[x][y+1]!='.')
		{
			vis[x][y+1]=1;
			pq.push({-(v+(s[x][y]!=s[x][y+1])),{x,y+1}});
		}
	}
	cout<<ans+1;
	return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:48:10: error: 'M' was not declared in this scope
   48 |   if(y+1<M && !vis[x][y+1] && s[x][y+1]!='.')
      |          ^