Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <queue>

#define INT_MAX = 100000001;
using namespace std;

struct node {
	int x;
	int y;
	int dis;
	node* p;
	node(int _x, int _y, int d) :x(_x), y(_y), dis(d), p(NULL){};
};

struct com {
	bool operator()(node x, node y)
	{
		return x.dis > y.dis;
	}
};
int main()
{
	int w, h;
	cin >> w >> h;
	vector<int>p;
	vector<int>q;
	for (int i = 0; i < w; ++i)
	{
		int temp;
		cin >> temp;
		p.push_back(temp);
	}
	for (int i = 0; i < h; ++i)
	{
		int temp;
		cin >> temp;
		q.push_back(temp);
	}
	int res = 0;
	priority_queue < node, vector<node>, com> heap;
	vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX)));
	for (int i = 0; i <= w; ++i)
	{
		for (int j = 0; j <= h; ++j)
		{
			node temp(i, j, INT_MAX);
			arr[i][j] = temp;
		}
	}
	arr[0][0].dis = 0;
	node cur = arr[0][0];
	
	heap.push(cur);
	vector<vector<bool> >flag(w+1, vector<bool>(h+1, false));
	//flag[0][0] = true;
	int count = 0;
	while (count < (h+1) * (w+1))
	{
		cur = heap.top();
		heap.pop();
		if (flag[cur.x][cur.y])
			continue;
		count++;
		//cout << cur.x << cur.y << endl;
		flag[cur.x][cur.y] = true;
		if(!(cur.x == 0&& cur.y == 0))
			res += cur.dis;
		if (cur.x > 0)
		{
			if (arr[cur.x - 1][cur.y].dis > p[cur.x - 1])
			{
				arr[cur.x - 1][cur.y].dis =  p[cur.x - 1];
				arr[cur.x - 1][cur.y].p = &arr[cur.x][cur.y];
			}
			heap.push(arr[cur.x - 1][cur.y]);
		}
		if(cur.x < w)
		{
			if (arr[cur.x + 1][cur.y].dis > p[cur.x])
			{
				arr[cur.x + 1][cur.y].dis = p[cur.x];
				arr[cur.x + 1][cur.y].p = &arr[cur.x][cur.y];
			}
			heap.push(arr[cur.x + 1][cur.y]);
		}
		if (cur.y < h)
		{
			if(arr[cur.x][cur.y + 1].dis > q[cur.y]);
			{
				arr[cur.x][cur.y + 1].dis = q[cur.y];
				arr[cur.x][cur.y + 1].p = &arr[cur.x][cur.y];
			}
			heap.push(arr[cur.x][cur.y+1]);
		}
		if (cur.y > 0)
		{
			if (arr[cur.x][cur.y - 1].dis > q[cur.y - 1])
			{
				arr[cur.x][cur.y - 1].dis = q[cur.y - 1];
				arr[cur.x][cur.y - 1].p = &arr[cur.x][cur.y];
			}
			heap.push(arr[cur.x][cur.y - 1]);
		}

	}
	cout << res;
	cin.get();
	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:51: error: expected primary-expression before '(' token
   43 |         vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX)));
      |                                                   ^
a.cc:43:60: error: expected primary-expression before '(' token
   43 |         vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX)));
      |                                                            ^
a.cc:6:17: error: expected primary-expression before '=' token
    6 | #define INT_MAX = 100000001;
      |                 ^
a.cc:43:67: note: in expansion of macro 'INT_MAX'
   43 |         vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX)));
      |                                                                   ^~~~~~~
a.cc:43:74: error: expected primary-expression before ')' token
   43 |         vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX)));
      |                                                                          ^
a.cc:6:17: error: expected primary-expression before '=' token
    6 | #define INT_MAX = 100000001;
      |                 ^
a.cc:48:41: note: in expansion of macro 'INT_MAX'
   48 |                         node temp(i, j, INT_MAX);
      |                                         ^~~~~~~
a.cc:48:48: error: expected primary-expression before ')' token
   48 |                         node temp(i, j, INT_MAX);
      |                                                ^