Submission #494300

#TimeUsernameProblemLanguageResultExecution timeMemory
494300wiwihoValley (BOI19_valley)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> #define starburststream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define ef(a) emplace_front(a) #define pob pop_back() #define pof pop_front() #define mp(a, b) make_pair(a, b) #define f first #define s second #define mt make_tuple #define gt(t, i) get<i>(t) #define tomax(a, b) ((a) = max((a), (b))) #define tomin(a, b) ((a) = min((a), (b))) #define topos(a) ((a) = (((a) % mod + mod) % mod)) #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tiii = tuple<int, int, int>; const ll mod = 1000000007; const ll max = 1ll << 60; template<typename a, typename b> ostream& operator<<(ostream& o, pair<a, b> p){ return o << '(' << p.f << ',' << p.s << ')'; } ll ifloor(ll a, ll b){ if(b < 0) a *= -1, b *= -1; if(a < 0) return (a - b + 1) / b; else return a / b; } ll iceil(ll a, ll b){ if(b < 0) a *= -1, b *= -1; if(a > 0) return (a + b - 1) / b; else return a / b; } int n; struct segmenttree{ vector<ll> st; int sz; explicit segmenttree(int sz): sz(sz){ st.resize(4 * sz, max); } void modify(int x, int v, int l = 1, int r = n, int id = 0){ //cerr << "modify " << x << " " << v << " " << l << " " << r << " " << sz << "\n"; //assert(l <= r); if(l == r){ st[id] = v; return; } int m = (l + r) / 2; if(x <= m) modify(x, v, l, m, 2 * id + 1); else modify(x, v, m + 1, r, 2 * id + 2); st[id] = min(st[2 * id + 1], st[2 * id + 2]); } ll query(int l, int r, int l = 1, int r = n, int id = 0){ if(l > r) return max; if(l <= l && r <= r) return st[id]; int m = (l + r) / 2; if(r <= m) return query(l, r, l, m, 2 * id + 1); else if(l > m) return query(l, r, m + 1, r, 2 * id + 2); else return min(query(l, r, l, m, 2 * id + 1), query(l, r, m + 1, r, 2 * id + 2)); } }; vector<vector<pii>> g; vector<bool> shop; vector<vector<int>> pr, in, out; vector<vector<ll>> dpt; vector<segmenttree> st; vector<int> sz, ts; vector<bool> del; const int sz = 20; vector<pii> e; int esc; void init(){ g.resize(n + 1); shop.resize(n + 1); pr.resize(sz, vector<int>(n + 1, -1)); in.resize(sz, vector<int>(n + 1, -1)); out.resize(sz, vector<int>(n + 1, -1)); dpt.resize(sz, vector<ll>(n + 1)); st.resize(sz, segmenttree(n)); sz.resize(n + 1); del.resize(n + 1); ts.resize(sz); e.resize(n); } void dfsg(int now, int p){ sz[now] = 1; for(pii i : g[now]){ if(i.f == p || del[i.f]) continue; dfsg(i.f, now); sz[now] += sz[i.f]; } } int cen; void dfsg2(int now, int p, int t){ int mx = t - sz[now]; for(pii i : g[now]){ if(i.f == p || del[i.f]) continue; mx = max(mx, sz[i.f]); dfsg2(i.f, now, t); } if(mx <= t / 2) cen = now; } void dfssub(int now, int p, ll d, int gd){ in[gd][now] = ++ts[gd]; pr[gd][now] = cen; dpt[gd][now] = d; if(shop[now]){ st[gd].modify(in[gd][now], d, 1, n, 0); } for(pii i : g[now]){ if(i.f == p || del[i.f]) continue; dfssub(i.f, now, d + i.s, gd); } out[gd][now] = ts[gd]; } void solve(int rt, int gd){ dfsg(rt, rt); dfsg2(rt, rt, sz[rt]); dfssub(cen, cen, 0, gd); //cerr << "solve " << cen << " "; //printv(sub[cen], cerr); del[cen] = true; for(pii i : g[cen]){ if(!del[i.f]) solve(i.f, gd + 1); } } ll oao = max; void query(int u1, int u2, int v){ for(int i = sz - 1; i >= 0; i--){ if(pr[i][v] == -1 || pr[i][esc] == -1) continue; if(pr[i][v] != pr[i][esc]) continue; int cen = pr[i][v]; if(pr[i][u1] != cen || pr[i][u2] != cen){ cout << "escaped\n"; return; } if(in[i][u1] > in[i][u2]) swap(u1, u2); if(in[i][u2] <= in[i][v] && out[i][v] <= out[i][u2]) break; if(in[i][u2] <= in[i][esc] && out[i][esc] <= out[i][u2]) break; cout << "escaped\n"; return; } ll ans = max; for(int i = sz - 1; i >= 0; i--){ if(pr[i][v] == -1) continue; int cen = pr[i][v]; if(pr[i][u1] != cen || pr[i][u2] != cen){ ans = min(ans, dpt[i][v] + st[i].query(in[i][cen], in[i][v] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][v] + 1, out[i][cen])); continue; } if(in[i][u1] > in[i][u2]) swap(u1, u2); if(in[i][u2] <= in[i][v] && out[i][v] <= out[i][u2]) continue; if(in[i][v] <= in[i][u2] && out[i][u2] <= out[i][v]){ ans = min(ans, dpt[i][v] + st[i].query(in[i][cen], in[i][v] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][v] + 1, out[i][cen])); } else if(in[i][u2] <= in[i][v]){ ans = min(ans, dpt[i][v] + st[i].query(in[i][cen], in[i][u2] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][u2] + 1, in[i][v] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][v] + 1, out[i][cen])); } else{ ans = min(ans, dpt[i][v] + st[i].query(in[i][cen], in[i][v] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][v] + 1, in[i][u2] - 1)); ans = min(ans, dpt[i][v] + st[i].query(out[i][u2] + 1, out[i][cen])); } } assert(ans == oao); if(ans == max) cout << "oo\n"; else cout << ans << "\n"; } void dfsbf(int now, int p, int u1, int u2, ll d){ if(now == esc) oao = -1; if(shop[now]) oao = min(oao, d); for(pii i : g[now]){ if(i.f == p) continue; if(mp(now, i.f) == mp(u1, u2) || mp(now, i.f) == mp(u2, u1)) continue; dfsbf(i.f, now, u1, u2, d + i.s); } } int main(){ starburststream int q, s; cin >> n >> s >> q >> esc; init(); for(int i = 1; i < n; i++){ int u, v, w; cin >> u >> v >> w; g[u].eb(mp(v, w)); g[v].eb(mp(u, w)); e[i] = mp(u, v); } for(int i = 0; i < s; i++){ int c; cin >> c; shop[c] = true; } solve(1, 0); /*cerr << "pr\n"; for(int i = 0; i < sz; i++){ printv(pr[i], cerr); } cerr << "in\n"; for(int i = 0; i < sz; i++){ printv(in[i], cerr); } cerr << "out\n"; for(int i = 0; i < sz; i++){ printv(out[i], cerr); }*/ for(int i = 0; i < q; i++){ int eid, v; cin >> eid >> v; int u1 = e[eid].f, u2 = e[eid].s; oao = max; dfsbf(v, v, u1, u2, 0); query(u1, u2, v); } return 0; }

Compilation message (stderr)

valley.cpp:82:32: error: redefinition of 'int l'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |                            ~~~~^~~~~
valley.cpp:82:18: note: 'int l' previously declared here
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |              ~~~~^
valley.cpp:82:43: error: redefinition of 'int r'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |                                       ~~~~^~~~~
valley.cpp:82:25: note: 'int r' previously declared here
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |                     ~~~~^
valley.cpp: In constructor 'segmenttree::segmenttree(int)':
valley.cpp:68:27: error: reference to 'max' is ambiguous
   68 |         st.resize(4 * sz, max);
      |                           ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
valley.cpp:44:10: note:                 'const ll max'
   44 | const ll max = 1ll << 60;
      |          ^~~
valley.cpp: In member function 'll segmenttree::query(int, int, int)':
valley.cpp:83:26: error: reference to 'max' is ambiguous
   83 |         if(l > r) return max;
      |                          ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
valley.cpp:44:10: note:                 'const ll max'
   44 | const ll max = 1ll << 60;
      |          ^~~
valley.cpp:84:14: warning: self-comparison always evaluates to true [-Wtautological-compare]
   84 |         if(l <= l && r <= r) return st[id];
      |            ~ ^~ ~
valley.cpp:84:24: warning: self-comparison always evaluates to true [-Wtautological-compare]
   84 |         if(l <= l && r <= r) return st[id];
      |                      ~ ^~ ~
valley.cpp:86:55: error: no matching function for call to 'segmenttree::query(int&, int&, int&, int&, int)'
   86 |         if(r <= m) return query(l, r, l, m, 2 * id + 1);
      |                                                       ^
valley.cpp:82:8: note: candidate: 'll segmenttree::query(int, int, int)'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |        ^~~~~
valley.cpp:82:8: note:   candidate expects 3 arguments, 5 provided
valley.cpp:87:63: error: no matching function for call to 'segmenttree::query(int&, int&, int, int&, int)'
   87 |         else if(l > m) return query(l, r, m + 1, r, 2 * id + 2);
      |                                                               ^
valley.cpp:82:8: note: candidate: 'll segmenttree::query(int, int, int)'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |        ^~~~~
valley.cpp:82:8: note:   candidate expects 3 arguments, 5 provided
valley.cpp:88:53: error: no matching function for call to 'segmenttree::query(int&, int&, int&, int&, int)'
   88 |         else return min(query(l, r, l, m, 2 * id + 1), query(l, r, m + 1, r, 2 * id + 2));
      |                                                     ^
valley.cpp:82:8: note: candidate: 'll segmenttree::query(int, int, int)'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |        ^~~~~
valley.cpp:82:8: note:   candidate expects 3 arguments, 5 provided
valley.cpp:88:88: error: no matching function for call to 'segmenttree::query(int&, int&, int, int&, int)'
   88 |         else return min(query(l, r, l, m, 2 * id + 1), query(l, r, m + 1, r, 2 * id + 2));
      |                                                                                        ^
valley.cpp:82:8: note: candidate: 'll segmenttree::query(int, int, int)'
   82 |     ll query(int l, int r, int l = 1, int r = n, int id = 0){
      |        ^~~~~
valley.cpp:82:8: note:   candidate expects 3 arguments, 5 provided
valley.cpp: At global scope:
valley.cpp:101:11: error: conflicting declaration 'const int sz'
  101 | const int sz = 20;
      |           ^~
valley.cpp:98:13: note: previous declaration as 'std::vector<int> sz'
   98 | vector<int> sz, ts;
      |             ^~
valley.cpp: In function 'void init()':
valley.cpp:109:41: error: no matching function for call to 'std::vector<std::vector<int> >::resize(std::vector<int>&, std::vector<int>)'
  109 |     pr.resize(sz, vector<int>(n + 1, -1));
      |                                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |              ~~~~~~~~~~^~~~~~~~~~
valley.cpp:110:41: error: no matching function for call to 'std::vector<std::vector<int> >::resize(std::vector<int>&, std::vector<int>)'
  110 |     in.resize(sz, vector<int>(n + 1, -1));
      |                                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |              ~~~~~~~~~~^~~~~~~~~~
valley.cpp:111:42: error: no matching function for call to 'std::vector<std::vector<int> >::resize(std::vector<int>&, std::vector<int>)'
  111 |     out.resize(sz, vector<int>(n + 1, -1));
      |                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |              ~~~~~~~~~~^~~~~~~~~~
valley.cpp:112:37: error: no matching function for call to 'std::vector<std::vector<long long int> >::resize(std::vector<int>&, std::vector<long long int>)'
  112 |     dpt.resize(sz, vector<ll>(n + 1));
      |                                     ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |              ~~~~~~~~~~^~~~~~~~~~
valley.cpp:113:33: error: no matching function for call to 'std::vector<segmenttree>::resize(std::vector<int>&, segmenttree)'
  113 |     st.resize(sz, segmenttree(n));
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = segmenttree; _Alloc = std::allocator<segmenttree>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = segmenttree; _Alloc = std::allocator<segmenttree>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = segmenttree]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<segmenttree>::size_type' {aka 'long unsigned int'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |              ~~~~~~~~~~^~~~~~~~~~
valley.cpp:116:17: error: no matching function for call to 'std::vector<int>::resize(std::vector<int>&)'
  116 |     ts.resize(sz);
      |                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
  937 |       resize(size_type __new_size)
      |              ~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:7: note:   candidate expects 2 arguments, 1 provided
valley.cpp: In function 'void dfsg2(int, int, int)':
valley.cpp:135:14: error: reference to 'max' is ambiguous
  135 |         mx = max(mx, sz[i.f]);
      |              ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
valley.cpp:44:10: note:                 'const ll max'
   44 | const ll max = 1ll << 60;
      |          ^~~
valley.cpp: At global scope:
valley.cpp:168:10: error: reference to 'max' is ambiguous
  168 | ll oao = max;
      |          ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-g