#include <bits/stdc++.h>
using namespace std;
struct ut
{
long long int dist;
int x,y;
const operator<(const ut& g)const
{
return dist > g.dist;
}
};
int main()
{
//ifstream cin("f.txt");
int n, m, d, i, j;
long long int cuccos=1600000000;
cin >> n >> m >> d;
int a[n][m];
ut t[n][m];
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
cin >> a[i][j];
t[i][j].dist=cuccos;
}
}
priority_queue<ut> q;
ut b={a[0][0], 0, 0};
t[0][0]={a[0][0], 0, 0};
q.push(t[0][0]);
while(!q.empty())
{
b=q.top();
q.pop();
if(b.x>0 && a[b.x-1][b.y]+b.dist<t[b.x-1][b.y].dist)
{
t[b.x-1][b.y] = {b.dist+a[b.x-1][b.y], b.x, b.y};
q.push({b.dist+a[b.x-1][b.y], b.x-1, b.y});
}
if(b.y>0 && a[b.x][b.y-1]+b.dist<t[b.x][b.y-1].dist)
{
t[b.x][b.y-1] = {b.dist+a[b.x][b.y-1], b.x, b.y};
q.push({b.dist+a[b.x][b.y-1], b.x, b.y-1});
}
if(b.x<n-1 && a[b.x+1][b.y]+b.dist<t[b.x+1][b.y].dist)
{
t[b.x+1][b.y] = {b.dist+a[b.x+1][b.y], b.x, b.y};
q.push({b.dist+a[b.x+1][b.y], b.x+1, b.y});
}
if(b.y<n-1 && a[b.x][b.y+1]+b.dist<t[b.x][b.y+1].dist)
{
t[b.x][b.y+1] = {b.dist+a[b.x][b.y+1], b.x, b.y};
q.push({b.dist+a[b.x][b.y+1], b.x, b.y+1});
}
}
t[0][0].x=-1;
t[0][0].y=-1;
int o=n-1, p=m-1;
ut plusz;
priority_queue<int> veg;
while(o!=-1)
{
veg.push(a[o][p]);
plusz=t[o][p];
o=plusz.x;
p=plusz.y;
}
while(d--)
{
i=veg.top();
cout << veg.top() << " ";
veg.pop();
veg.push(i/2);
}
i=0;
while(!veg.empty())
{
i+=veg.top();
veg.pop();
}
cout << i;
return 0;
}
Forditási hiba
open /var/local/lib/isolate/443/box/a.out: no such file or directory
main.cpp:8:11: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
8 | const operator<(const ut& g)const
| ^~~~~~~~