Language: C++

#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

vector<vector<pair<int, int>>> g;
vector<bool> visited;
vector<long long> dist;
queue<pair<int, long long>> q;

int main() {
    int N, M;
    cin >> N >> M;

    g = vector<vector<pair<int, long long>>>(N + 1);
    visited = vector<bool>(N + 1, false);
    dist = vector<long long>(N + 1, INF);

    REP(i, M) {
        int s, t;
        cin >> s >> t;

        s--;
        t--;

        int w;
        cin >> w;

        g[s].emplace_back(t, w);
        g[t].emplace_back(s, -w);
    }

    REP(i, N) {
        if (visited[i] == false) {
            q.emplace(i, 0);

            while (!q.empty()) {
                auto& p = q.front();
                q.pop();

                for (auto& e : g[p.first]) {
                    if (visited[e.first]) {
                        if (dist[e.first] != p.second + e.second) {
                            cout << "No" << endl;
                            return 0;
                        }
                    } else {
                        long long next_dist = p.second + e.second;
                        dist[e.first] = next_dist;
                        visited[e.first] = true;
                        q.emplace(e.first, next_dist);
                    }
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:51: error: no match for 'operator=' (operand types are 'std::vector<std::vector<std::pair<int, int> > >' and 'std::vector<std::vector<std::pair<int, long long int> > >')
   26 |     g = vector<vector<pair<int, long long>>>(N + 1);
      |                                                   ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:4:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, long long int> > >' to 'const std::vector<std::vector<std::pair<int, int> > >&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, long long int> > >' to 'std::vector<std::vector<std::pair<int, int> > >&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, long long int> > >' to 'std::initializer_list<std::vector<std::pair<int, int> > >'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~