239852026-02-03 08:29:18szabelrHálózati átvitelcpp17Forditási hiba
// Hálózati átvitel.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k, h;
    cin >> n >> m >> k >> h;
    vector<vector<pair<int,int>>> adj(n + 1);
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].push_back({ b,c });
        adj[b].push_back({ a,c });
    }
    vector<int> mini(n + 1, -1);
    mini[k] = 0;
    queue<pair<int, pair<int, int>>> q;
    q.push({ 0,{k,INT_MAX} });
    while (!q.empty())
    {
        auto it = q.front();
        q.pop();
        int stops = it.first;
        int node = it.second.first;
        int speed = it.second.second;
        if (stops > h) continue;
        for (auto iterator : adj[node])
        {
            int adjNode = iterator.first;
            int curSpeed = iterator.second;
            if (min(speed, curSpeed) > mini[adjNode])
            {
                mini[adjNode] = min(speed, curSpeed);
                q.push({ stops + 1,{adjNode,mini[adjNode]} });
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (i != k)
            cout << mini[i] << endl;
        else
            cout << 0 << endl;
    }
       

}
Forditási hiba
open /var/local/lib/isolate/439/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:26:19: error: 'INT_MAX' was not declared in this scope
   26 |     q.push({ 0,{k,INT_MAX} });
      |                   ^~~~~~~
main.cpp:7:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    6 | #include <queue>
  +++ |+#include <climits>
    7 | using namespace std;
main.cpp:26:11: error: no matching function for call to 'std::queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   26 |     q.push({ 0,{k,INT_MAX} });
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/queue:64,
                 from main.cpp:6:
/usr/include/c++/12/bits/stl_queue.h:285:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::deque<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; value_type = std::pair<int, std::pair<int, int> >]'
  285 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/12/bits/stl_queue.h:285:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<std::pair<int, std::pair<int, int> > >::value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  285 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/12/bits/stl_queue.h:290:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::deque<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; value_type = std::pair<int, std::pair<int, int> >]'
  290 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/12/bits/stl_queue.h:290:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, std::pair<int, int> >...