Submission #619202

# Submission time Handle Problem Language Result Execution time Memory
619202 2022-08-02T10:30:40 Z Je_O Dynamic Diameter (CEOI19_diameter) C++17
Compilation error
0 ms 0 KB
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 5;
const int LOG = 18;
const int INF = 2e9 + 5;
vector<iii> vec;
vector<ii> lst[N];
int dist[N];

void solve_sub2(int n, int q, int w){
    int last = 0;
    while(q--){
        int d, e; cin >> d >> e;
        d = (d + last) % (n - 1);
        e = (e + last) % w;
        vec[d].fi = e;
        for(int i = 1; i <= n; ++i)lst[i].clear();
        for(int i = 0; i < n - 1; ++i){
            lst[vec[i].se.fi].pb(mp(vec[i].se.se, vec[i].fi));
            lst[vec[i].se.se].pb(mp(vec[i].se.fi, vec[i].fi));
        }
        for(int i = 1; i <= n; ++i)dist[i] = INF;
        queue<int> q;
        q.push(1);
        dist[1] = 0;
        while(!q.empty()){
            int cur = q.front(); q.pop();
            for(int i = 0; i < lst[cur].size(); ++i){
                int nx = lst[cur][i].fi;
                int cs = dist[cur] + lst[cur][i].se;
                if(cs < dist[nx]){
                    dist[nx] = cs;
                    q.push(nx);
                }
            }
        }
        ii maxdist = mp(-1, -1);
        for(int i = 1; i <= n; ++i){
            maxdist = max(maxdist, mp(dist[i], i));
        }
        for(int i = 1; i <= n; ++i)dist[i] = INF;
        q.push(maxdist.se);
        dist[maxdist.se] = 0;
        while(!q.empty()){
            int cur = q.front(); q.pop();
            for(int i = 0; i < lst[cur].size(); ++i){
                int nx = lst[cur][i].fi;
                int cs = dist[cur] + lst[cur][i].se;
                if(cs < dist[nx]){
                    dist[nx] = cs;
                    q.push(nx);
                }
            }
        }
        int ans = -1;
        for(int i = 1; i <= n; ++i){
            ans = max(ans, dist[i]);
        }
        last = ans;
        cout << ans << '\n';
    }
    return;
}

map<int, int> mep;

void solve_sub3(int n, int q, int w){
    int last = 0;
    while(q--){
        int d, e; cin >> d >> e;
        d = (d + last) % (n - 1);
        e = (e + last) % w;
        --mep[vec[d].fi];
        if(mep[vec[d].fi] == 0)mep.erase(vec[d].fi);
        ++mep[e];
        vec[d].fi = e;
        auto it = mep.end();
        --it;
        int ans = it->fi;
        if(it->se > 1)ans += it->fi;
        else{
            --it;
            ans += it->fi;
        }
        last = ans;
        cout << ans << '\n';
    }
    return;
}

int par[N];
int depth[N];
int cost[N];
int ar[N];
int lf[N], rg[N];

struct node{
    ii mx1, mx2; int lz;
};

node st[4 * N];

node merge(node a, node b){
    return {max(a.mx1, b.mx1), max(min(a.mx1, b.mx1), max(a.mx2, b.mx2)), 0};
}

void build(int idx, int l, int r){
    if(l == r){
        st[l] = {mp(ar[l], l), mp(-1, -1), 0};
        return;
    }
    int m = (l + r)/2;
    build(idx * 2, l, m);
    build(idx * 2 + 1, m + 1, r);
    st[idx] = merge(st[idx * 2], st[idx * 2 + 1]);
    return;
}

void apply(int idx, int l, int r, int v){
    st[idx].mx1.fi += v;
    st[idx].mx2.fi += v;
    st[idx].lz += v;
    return;
}

void pushdown(int idx, int l, int r){
    if(st[idx].lz == 0)return;
    int m = (l + r)/2;
    apply(idx * 2, l, m, st[idx].lz);
    apply(idx * 2 + 1, m + 1, r, st[idx].lz);
    st[idx].lz = 0;
    return;
}

void upd(int idx, int l, int r, int x, int y, int v){
    if(l > y || r < x)return;
    if(l >= x && r <= y){
        apply(idx, l, r, v);
        return;
    }
    pushdown(idx, l, r);
    int m = (l + r)/2;
    upd(idx * 2, l, m, x, y, v);
    upd(idx * 2 + 1, m + 1, r, x, y, v);
    st[idx] = merge(st[idx * 2], st[idx * 2 + 1]);
    return;
}

node get(int idx, int l, int r, int x, int y){
    if(l > y || r < x)return {mp(-1, -1), mp(-1, -1), 0};
    if(l >= x && r <= y)return st[idx];
    pushdown(idx, l, r);
    int m = (l + r)/2;
    return merge(get(idx * 2, l, m, x, y), get(idx * 2 + 1, m + 1, r, x, y));
}

ii dfs(int idx, int p, int cur_sum){
    par[idx] = p;
    ar[idx] = cur_sum;
    ii res = mp(INF, 0);
    for(int i = 0; i < lst[idx].size(); ++i){
        int nx = lst[idx][i].fi;
        if(nx == p)continue;
        cost[nx] = lst[idx][i].se;
        depth[nx] = depth[idx] + 1;
        ii cur = dfs(nx, idx, cur_sum + lst[idx][i].se);
        res.fi = min(res.fi, cur.fi);
        res.se = max(res.se, cur.se);
    }
    lf[idx] = res.fi; rg[idx] = res.se;
    return res;
}

node rs[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, q, w; cin >> n >> q >> w;
    bool sub3 = true;
    for(int i = 0; i < n - 1; ++i){
        int a, b, c; cin >> a >> b >> c;
        lst[a].pb(mp(b, c));
        lst[b].pb(mp(a, c));
        vec.pb(mp(c, mp(a, b)));
        ++mep[c];
        if(a != 1 && b != 1)sub3 = false;
    }
    if(n <= 5000 && q <= 5000){
        solve_sub2(n, q, w);
        return 0;
    }
    if(sub3){
        solve_sub3(n, q, w);
        return 0;
    }
    mep.clear();
    dfs(1, -1, 0);
    int id_l = 0;
    for(int i = 1; i <= n; ++i){
        if(lst[i].size() == 1){
            id_l = i;
            break;
        }
    }
    build(1, 1, n);
    for(int i = 1; i < id_l; ++i){
        rs[i] = get(1, 1, n, lf[i], rg[i]);
        rs[i].mx1.fi -= ar[i];
        rs[i].mx2.fi -= ar[i];
        mep[rs[i].mx1.fi + rs[i].mx2.fi]++;
    }
    int last = 0;
    while(q--){
        int d, e; cin >> d >> e;
        d = (d + last) % (n - 1);
        e = (e + last) % w;
        int x = vec[d].se.fi, y = vec[d].se.se;
        if(depth[x] < depth[y])swap(x, y);
        upd(1, 1, n, lf[x], rg[x], e - cost[x]);
        node res;
        if(par[x] != -1)res = get(1, 1, n, lf[par[x]], rg[par[x]]);
        int idx = x;
        while(par[idx] != -1){
            idx = par[idx];
            node last_rs = rs[idx];
            int last_sum = rs[idx].mx1.fi + rs[idx].mx2.fi;=
            node cur = res;
            cur.mx1.fi -= ar[idx];
            cur.mx2.fi -= ar[idx];
            vector<ii> vecs;
            vecs.pb(cur.mx1); vecs.pb(cur.mx2);
            vecs.pb(rs[idx].mx1); vecs.pb(rs[idx].mx2);
            sort(vecs.begin(), vecs.end());
            reverse(vecs.begin(), vecs.end());
            rs[idx].mx1 = rs[idx].mx2 = mp(-1, -1);
            for(int i = 0; i < vecs.size(); ++i){
                if(i > 0 && vecs[i] == vecs[i - 1])continue;
                if(rs[idx].mx1 == mp(-1, -1))rs[idx].mx1 = vecs[i];
                else if(rs[idx].mx2 == mp(-1, -1))rs[idx].mx2 = vecs[i];
            }
            if(last_rs != rs[idx]){
                mep[last_sum]--;
                mep[rs[idx].mx1.fi + rs[idx].mx2.fi]++;
            }
        }
        cost[x] = e;
        vec[d].fi = e;
        auto it = mep.end();
        --it;
        while(it->se == 0){
            mep.erase(it->fi);
            --it;
        }
        int ans = it->fi;
        if(it->se > 1){
            ans += it->fi;
        }else{
            while(it->se == 0){
                mep.erase(it->fi);
                --it;
            }
            --it;
            ans += it->fi;
        }
        last = ans;
        cout << ans << '\n';
    }
    return 0;
}

Compilation message

diameter.cpp: In function 'void solve_sub2(int, int, int)':
diameter.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i = 0; i < lst[cur].size(); ++i){
      |                            ~~^~~~~~~~~~~~~~~~~
diameter.cpp:57:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for(int i = 0; i < lst[cur].size(); ++i){
      |                            ~~^~~~~~~~~~~~~~~~~
diameter.cpp: In function 'ii dfs(int, int, int)':
diameter.cpp:172:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  172 |     for(int i = 0; i < lst[idx].size(); ++i){
      |                    ~~^~~~~~~~~~~~~~~~~
diameter.cpp: In function 'int main()':
diameter.cpp:237:60: error: expected primary-expression before '=' token
  237 |             int last_sum = rs[idx].mx1.fi + rs[idx].mx2.fi;=
      |                                                            ^
diameter.cpp:238:18: error: expected primary-expression before 'cur'
  238 |             node cur = res;
      |                  ^~~
diameter.cpp:239:13: error: 'cur' was not declared in this scope
  239 |             cur.mx1.fi -= ar[idx];
      |             ^~~
diameter.cpp:247:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  247 |             for(int i = 0; i < vecs.size(); ++i){
      |                            ~~^~~~~~~~~~~~~
diameter.cpp:252:24: error: no match for 'operator!=' (operand types are 'node' and 'node')
  252 |             if(last_rs != rs[idx]){
      |                ~~~~~~~ ^~ ~~~~~~~
      |                |                |
      |                node             node
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1064:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)'
 1064 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1064:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1144:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)'
 1144 |     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1144:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1237:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1237 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1237:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1311:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)'
 1311 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1311:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1405:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1405 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1405:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1479:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)'
 1479 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1479:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:1579:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1579 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1579:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/regex.h:2126:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const std::__cxx11::match_results<_BiIter, _Alloc>&, const std::__cxx11::match_results<_BiIter, _Alloc>&)'
 2126 |     operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:2126:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/stl_pair.h:496:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  496 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:496:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::pair<_T1, _T2>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/stl_iterator.h:372:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  372 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:372:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::reverse_iterator<_Iterator>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/stl_iterator.h:410:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  410 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:410:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::reverse_iterator<_Iterator>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/stl_iterator.h:1444:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1444 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1444:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::move_iterator<_IteratorL>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/stl_iterator.h:1501:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1501 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1501:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::move_iterator<_IteratorL>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/iosfwd:40,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/postypes.h:227:5: note: candidate: 'template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)'
  227 |     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/postypes.h:227:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::fpos<_StateT>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/string:41,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:4:
/usr/include/c++/10/bits/allocator.h:213:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&)'
  213 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/10/bits/allocator.h:213:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'const std::allocator<_CharT>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:4:
/usr/include/c++/10/string_view:525:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)'
  525 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:525:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:4:
/usr/include/c++/10/string_view:531:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::__type_identity_t<std::basic_string_view<_CharT, _Traits> >)'
  531 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:531:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:4:
/usr/include/c++/10/string_view:538:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::__type_identity_t<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)'
  538 |     operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:538:5: note:   template argument deduction/substitution failed:
diameter.cpp:252:33: note:   'node' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  252 |             if(last_rs != rs[idx]){
      |                                 ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,