2560 | 2023-01-17 09:48:26 | zsebi | Villanyautó | cpp11 | Compilation error |
// villanyauto.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <queue>
#define ll long long
using namespace std;
struct ut
{
ll hova, hossz;
};
priority_queue<ut>que;
ut akt;
bool operator<(const ut& a, const ut& b)
{
return a.hossz > b.hossz;
}
struct adat
{
bool lat = false;
ll hossz = LLONG_MAX;
vector < pair<ll, ll>>sz;
};
vector<adat>x;
ll n, m, k, a, b, c;
int main()
{
cin >> n >> m >> k;
x.resize(n + 1);
for (int i = 1; i <= m; ++i)
{
cin >> a >> b >> c;
x[a].sz.push_back({ b,c });
}
ll ans = 0;
que.push({ 1,0 });
while (!que.empty())
{
bool ok = false;
akt = que.top();
while (x[akt.hova].lat && !que.empty())
{
que.pop();
if (!que.empty())akt = que.top();
}
if (que.empty())break;
que.pop();
x[akt.hova].lat = true;
x[akt.hova].hossz = akt.hossz;
for (auto& e : x[akt.hova].sz)
{
if (!x[e.first].lat && x[e.first].hossz > (akt.hossz + e.second))
{
ok = true;
x[e.first].hossz = akt.hossz + e.second;
que.push({ e.first , akt.hossz + e.second });
}
if (!ok)ans += x[akt.hova].hossz;
}
}
cout << ans / k;
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
exit status 1
main.cpp:23:16: error: 'LLONG_MAX' was not declared in this scope
23 | ll hossz = LLONG_MAX;
| ^~~~~~~~~
main.cpp:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
5 | #include <queue>
+++ |+#include <climits>
6 |
Exited with error status 1