제출 #1182342

#제출 시각아이디문제언어결과실행 시간메모리
1182342qwushaGraph (BOI20_graph)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
/*
#pragma GCC optimize("O3")
#include <bitset>
#pragma GCC target("avx2")*/
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int inf = 1e15;


vector<vector<pair<int, int>>> g;
vector<int> val;
int curbest = inf;
int nowsum = 0;
vector<int> chan;

bool dfs(int v, int q) {
    chan.push_back(v);
    val[v] = q;
    nowsum += abs(q);
    if (nowsum >= curbest)
        return 0;
    for (auto [u, w] : g[v]) {
        if (val[u] != inf) {
            if (val[u] + val[v] != w)
                return 0;
        } else {
            int res = dfs(u, w - val[v]);
            if (res == 0)
                return 0;
        }
    }
    return 1;
}

vector<int> col;

void dfs_comp(int v, int c) {
    col[v] = c;
    for (auto [u, w] : g[v]) {
        if (col[u] == -1) {
            dfs_comp(u, c);
        }
    }
}

int K = 400;



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    g.resize(n);
    unordered_map<int, int> mp;
    for (int i = 0; i < m; i++) {
        int v, u, w;
        cin >> v >> u >> w;
        if (mp.find((v - 1) * 1e7 + (u - 1)) != mp.end()) {
            if (mp[(v - 1) * 1e7 + (u - 1)] != w * 2) {
                cout << "NO" << '\n';
                return 0;
            }
        } else {
            mp[(v - 1) * 1e7 + (u - 1)] = w * 2;
            mp[(u - 1) * 1e7 + (v - 1)] = w * 2;
        }
        g[v - 1].push_back({u - 1, w * 2});
        g[u - 1].push_back({v - 1, w * 2});
    }
    vector<int> indbig(n, -1);
    map<int, int> indnorm;
    int B = 0;
    for (int i = 0; i < n; i++) {
        if (g[i].size() > K) {
            indbig[i] = B;
            indnorm[B] = i;
            B++;
        }
    }
    vector<vector<pair<int, int>>> gB(B);
    for (int i = 0; i < n; i++) {
        if (indbig[i] == -1)
            continue;
        for (auto [u, q] : g[i]) {
            if (indbig[u] != -1) {
                gB[indbig[i]].push_back({indbig[u], q});
            }
        }
    }
    vector<pair<int, int>> know;
    for (int i = 0; i < n; i++) {
        if (indbig[i] == -1) {
            for (auto [j, w1] : g[i]) {
                for (auto [q, w2] : g[i]) {
                    if (j == q)
                        continue;
                    if (mp.find({j, q}) != mp.end()) {
                        int w3 = mp[{j, q}];
                        if (w1 != w2 || w2 != w3 || w1 != w3) {
                            if (w1 + w2 + w3 == 8) {
                                if (w1 == 4)
                                    know.push_back({q, 0});
                                else if (w2 == 4)
                                    know.push_back({j, 0});
                                else
                                    know.push_back({i, 0});
                            } else {
                                if (w1 == 2)
                                    know.push_back({q, 3});
                                else if (w2 == 2)
                                    know.push_back({j, 3});
                                else
                                    know.push_back({i, 3});
                            }
                        }
                    }
                }
            }
        }
    }
    if (1) {
        for (int i = 0; i < B; i++) {
            for (int j = i + 1; j < B; j++) {
                int ni = indnorm[i], nj = indnorm[j];
                if (mp.find({ni, nj}) == mp.end())
                    continue;
                for (int q = j + 1; q < B; q++) {
                    int nq = indnorm[q];
                    if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
                        int w1 = mp[{ni, nj}];
                        int w2 = mp[{ni, nq}];
                        int w3 = mp[{nj, nq}];
                        if (w1 + w2 + w3 == 8) {
                            if (w1 == 4)
                                know.push_back({nq, 0});
                            else if (w2 == 4)
                                know.push_back({nj, 0});
                            else
                                know.push_back({ni, 0});
                        } else {
                            if (w1 == 2)
                                know.push_back({nq, 3});
                            else if (w2 == 2)
                                know.push_back({nj, 3});
                            else
                                know.push_back({ni, 3});
                        }
                    }
                }
            }
        }
    }
    col.resize(n, -1);
    vector<int> boss;
    for (int i = 0; i < n; i++) {
        if (col[i] == -1) {
            boss.push_back(i);
            dfs_comp(i, boss.size() - 1);
        }
    }
    vector<vector<int>> comps(boss.size());
    for (int i = 0; i < n; i++) {
        comps[col[i]].push_back(i);
    }
    vector<pair<int, int>> known(boss.size(), {-1, -1});
    for (auto par : know) {
        known[col[par.fi]] = par;
    }
    val.assign(n, inf);
    bool done = 1;
    int answer = 0;
    vector<pair<int, int>> bq(boss.size());
    vector<int> num(boss.size());
    for (int i = 0; i < boss.size(); i++) {
        double r = (double)comps[i].size() / (double)n;
        num[i] = max(1ll, (int)(r * 8));
    }
    for (int co = 0; co < boss.size(); co++) {
        bool ok = 0;
        int indb = -1;
        curbest = inf;
        int bst = -1;
        if (known[co].fi != -1) {
            int st = known[co].fi;
            int stval = known[co].se;
            nowsum = 0;
            for (auto el : chan) {
                val[el] = inf;
            }
            chan.clear();
            if (dfs(st, stval)) {
                ok = 1;
                if (nowsum < curbest) {
                    curbest = nowsum;
                    indb = stval;
                    bst = st;
                }
            }
        } else {
            for (int qw = 0; qw < num[co]; qw++) {
                int st = comps[co][rnd() % comps[co].size()];
                int l = -8, r = 15;
                if (comps.size() > n / 10) {
                    l = -18;
                    r = 25;
                }
                if (comps.size() > n / 2) {
                    l = -28;
                    r = 35;
                }
                for (int q = 0; q <= r; q++) {
                    nowsum = 0;
                    for (auto el : chan) {
                        val[el] = inf;
                    }
                    chan.clear();
                    if (dfs(st, q)) {
                        ok = 1;
                        if (nowsum < curbest) {
                            curbest = nowsum;
                            indb = q;
                            bst = st;
                        }
                    }

                }

                for (int q = -1; q >= l; q--) {
                    nowsum = 0;
                    for (auto el : chan) {
                        val[el] = inf;
                    }
                    chan.clear();
                    if (dfs(st, q)) {
                        ok = 1;
                        if (nowsum < curbest) {
                            curbest = nowsum;
                            indb = q;
                            bst = st;
                        }
                    }

                }
            }
        }
        bq[co] = {indb, bst};
        if (ok == 0) {
            done = 0;
            break;
        }
        answer += curbest;
    }
    if (done == 0) {
        cout << "NO" << '\n';
        return 0;
    } else {
        cout << "YES" << '\n';
        for (int i = 0; i < n; i++) {
            val[i] = inf;
        }
        curbest = inf;
        nowsum = 0;
        for (int co = 0; co < boss.size(); co++) {
            dfs(bq[co].se, bq[co].fi);
        }
        for (auto el : val) {
            cout << el * 0.5 << ' ';
        }
        cout << '\n';
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Graph.cpp: In function 'int main()':
Graph.cpp:105:32: error: no matching function for call to 'std::unordered_map<long long int, long long int>::find(<brace-enclosed initializer list>)'
  105 |                     if (mp.find({j, q}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:874:9: note: candidate: 'template<class _Kt> decltype (((std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  874 |         find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:874:9: note:   template argument deduction/substitution failed:
Graph.cpp:105:32: note:   couldn't deduce template parameter '_Kt'
  105 |                     if (mp.find({j, q}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:885:9: note: candidate: 'template<class _Kt> decltype (((const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) const [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  885 |         find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:885:9: note:   template argument deduction/substitution failed:
Graph.cpp:105:32: note:   couldn't deduce template parameter '_Kt'
  105 |                     if (mp.find({j, q}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:868:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  868 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:868:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  868 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:879:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) const [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::const_iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  879 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:879:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  879 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~
Graph.cpp:106:36: error: no match for 'operator[]' (operand types are 'std::unordered_map<long long int, long long int>' and '<brace-enclosed initializer list>')
  106 |                         int w3 = mp[{j, q}];
      |                                    ^
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:979:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  979 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:979:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  979 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:983:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  983 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:983:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::unordered_map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  983 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Graph.cpp:133:28: error: no matching function for call to 'std::unordered_map<long long int, long long int>::find(<brace-enclosed initializer list>)'
  133 |                 if (mp.find({ni, nj}) == mp.end())
      |                     ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:874:9: note: candidate: 'template<class _Kt> decltype (((std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  874 |         find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:874:9: note:   template argument deduction/substitution failed:
Graph.cpp:133:28: note:   couldn't deduce template parameter '_Kt'
  133 |                 if (mp.find({ni, nj}) == mp.end())
      |                     ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:885:9: note: candidate: 'template<class _Kt> decltype (((const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) const [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  885 |         find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:885:9: note:   template argument deduction/substitution failed:
Graph.cpp:133:28: note:   couldn't deduce template parameter '_Kt'
  133 |                 if (mp.find({ni, nj}) == mp.end())
      |                     ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:868:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  868 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:868:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  868 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:879:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) const [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::const_iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  879 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:879:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  879 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~
Graph.cpp:137:32: error: no matching function for call to 'std::unordered_map<long long int, long long int>::find(<brace-enclosed initializer list>)'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:874:9: note: candidate: 'template<class _Kt> decltype (((std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  874 |         find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:874:9: note:   template argument deduction/substitution failed:
Graph.cpp:137:32: note:   couldn't deduce template parameter '_Kt'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:885:9: note: candidate: 'template<class _Kt> decltype (((const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) const [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  885 |         find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:885:9: note:   template argument deduction/substitution failed:
Graph.cpp:137:32: note:   couldn't deduce template parameter '_Kt'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                         ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:868:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  868 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:868:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  868 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:879:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) const [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::const_iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  879 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:879:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  879 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~
Graph.cpp:137:65: error: no matching function for call to 'std::unordered_map<long long int, long long int>::find(<brace-enclosed initializer list>)'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                                                          ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:874:9: note: candidate: 'template<class _Kt> decltype (((std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  874 |         find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:874:9: note:   template argument deduction/substitution failed:
Graph.cpp:137:65: note:   couldn't deduce template parameter '_Kt'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                                                          ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:885:9: note: candidate: 'template<class _Kt> decltype (((const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>*)this)->std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h._M_find_tr(__x)) std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const _Kt&) const [with _Kt = _Kt; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  885 |         find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/11/bits/unordered_map.h:885:9: note:   template argument deduction/substitution failed:
Graph.cpp:137:65: note:   couldn't deduce template parameter '_Kt'
  137 |                     if (mp.find({ni, nq}) != mp.end() && mp.find({nq, nj}) != mp.end()) {
      |                                                          ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:868:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  868 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:868:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  868 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:879:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) const [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator = std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::const_iterator; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  879 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/11/bits/unordered_map.h:879:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  879 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~
Graph.cpp:138:36: error: no match for 'operator[]' (operand types are 'std::unordered_map<long long int, long long int>' and '<brace-enclosed initializer list>')
  138 |                         int w1 = mp[{ni, nj}];
      |                                    ^
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:979:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  979 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:979:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  979 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:983:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  983 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:983:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::unordered_map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  983 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Graph.cpp:139:36: error: no match for 'operator[]' (operand types are 'std::unordered_map<long long int, long long int>' and '<brace-enclosed initializer list>')
  139 |                         int w2 = mp[{ni, nq}];
      |                                    ^
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:979:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  979 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:979:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  979 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:983:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  983 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:983:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::unordered_map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  983 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Graph.cpp:140:36: error: no match for 'operator[]' (operand types are 'std::unordered_map<long long int, long long int>' and '<brace-enclosed initializer list>')
  140 |                         int w3 = mp[{nj, nq}];
      |                                    ^
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Graph.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:979:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  979 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:979:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const long long int&'}
  979 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/unordered_map.h:983:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = long long int]'
  983 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:983:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::unordered_map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  983 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~