34022023-02-27 12:54:14kdbHálózati átvitelcpp11Forditási hiba
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

std::ostream& operator<<(std::ostream& os, const std::vector<int>& input)
{
    for (auto const& i : input) {
        os << i << "\n";
    }
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m, k, h;
    cin >> n >> m >> k >> h;
    vector<int>ki(n + 1);
    vector<int>ki2(n + 1);
    vector<vector<pair<int, int>>>vec(n + 1);

    for (size_t i = 0; i < m; i++)
    {
        int a, v, w;
        cin >> u >> v >> w;
        vec[u].push_back({ v,w });
        vec[v].push_back({ u,w });
    }

    ki[k] = INT_MAX;
    ki2[k] = INT_MAX;

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 1; j < n + 1; j++)
        {
            for (auto q : vec[j])
            {
                if (ki[q.first] < min(q.second, ki2[j]))
                {
                    ki[q.first] = min(q.second, ki2[j]);
                }
            }
        }
        ki2 = ki;
    }
    ki[k] = 0;
    ki.erase(ki.begin());
    cout << ki;
    return 0;
}
/*
5 6 1 2
1 2 2
1 5 4
1 3 2
1 4 3
5 4 1
5 3 4
*/
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:29:16: error: 'u' was not declared in this scope
   29 |         cin >> u >> v >> w;
      |                ^
main.cpp:31:25: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   31 |         vec[v].push_back({ u,w });
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from main.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const val...