4271 | 2023-03-21 09:49:13 | tamasmark | Hálózati átvitel | cpp17 | Compilation error |
// halozatatvitel.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#define ll long long
using namespace std;
struct ut
{
ll hova, hossz;
};
struct adat
{
bool lat;
ll tav = LLONG_MIN,lep;
vector<ut>sz;
};
priority_queue<ut>que;
ut akt;
bool operator<(const ut a, const ut b)
{
return a.hossz < b.hossz;
}
ll n, i, a, b, c, db,m,k,h;
int main()
{
cin >> n >> m>>k>>h;
vector<adat>x(n+1);
for (i = 1; i <= m; ++i)
{
cin >> a >> b >> c;
x[a].sz.push_back({ b,c });
x[b].sz.push_back({ a,c });
}
que.push({ k,LLONG_MAX });
while (!que.empty())
{
akt = que.top();
while (!que.empty() && x[akt.hova].lat)
{
que.pop();
if (!que.empty()) akt = que.top();
}
//que.pop();
if (que.empty()) break;
x[akt.hova].lat = true;
x[akt.hova].tav = akt.hossz;
for (auto& e : x[akt.hova].sz)
{
if (!x[e.hova].lat && x[e.hova].tav < min(akt.hossz, e.hossz) && x[akt.hova].lep + 1 <= h)
{
x[e.hova].tav = min(akt.hossz, e.hossz);
if(!x[e.hova].lep)x[e.hova].lep = x[akt.hova].lep + 1;
que.push({ e.hova,min(akt.hossz , e.hossz) });
}
else if (x[akt.hova].lep + 1 > h&&!x[e.hova].lat) x[e.hova].tav = -1;
}
}
x[k].tav = 0;
for (i = 1; i <= n; ++i) cout << x[i].tav << "\n";
return 0;
}
/*
7 8 1 2
1 2 2
1 5 4
1 3 2
1 4 3
5 4 1
5 3 4
5 6 1
6 7 8
*/
// 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:19:14: error: 'LLONG_MIN' was not declared in this scope
19 | ll tav = LLONG_MIN,lep;
| ^~~~~~~~~
main.cpp:9:1: note: 'LLONG_MIN' is defined in header '<climits>'; did you forget to '#include <climits>'?
8 | #include <algorithm>
+++ |+#include <climits>
9 | #define ll long long
main.cpp: In function 'int main()':
main.cpp:41:18: error: 'LLONG_MAX' was not declared in this scope
41 | que.push({ k,LLONG_MAX });
| ^~~~~~~~~
main.cpp:41:18: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
main.cpp:41:13: error: no matching function for call to 'std::priority_queue<ut>::push(<brace-enclosed initializer list>)'
41 | que.push({ k,LLONG_MAX });
| ~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
from main.cpp:7:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const valu...