为什么为RE啊!!!!
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n = 0 , m = 0 , X = 0;
int p = 0 , q = 0 , ans = 0;
array<array<int , 1000> , 1000> val , vis;
array<int , 100> dx = {0 , 1 , -1 , 0 , 0};
array<int , 100> dy = {0 , 0 , 0 , 1 , -1};
struct Point{
int x;
int y;
int val;
};
bool operator < (const Point &a , const Point &b)
{
return a.val < b.val;
}
bool operator > (const Point &a , const Point &b)
{
return a.val > b.val;
}
priority_queue<Point , vector<Point> , greater<Point> > que;
signed main()
{
cin >> n >> m >> X;
cin >> p >> q;
for(int i = 1;i <= n;++ i)
{
for(int j = 1;j <= m;++ j)
{
cin >> val[i][j];
}
}
que.push({p , q , val[p][q]});
while(!que.empty())
{
auto x = que.top().x , y = que.top().y;
que.pop();
if(vis[x][y]) continue;
if(val[x][y] * X < ans || (x == p && y == q))
{
que.pop();
vis[x][y] = true;
ans += val[x][y];
for(int k = 1;k <= 4;++ k)
{
int nxtx = x + dx[k] , nxty = y + dy[k];
if(nxtx >= 1 && nxtx <= n && nxty >= 1 && nxty <= m && !vis[nxtx][nxty])
{
Point nxt = {nxtx , nxty , val[nxtx][nxty]};
que.push(nxt);
}
}
}
else break;
}
cout << ans << endl;
return 0;
}