Submission #1148578

#TimeUsernameProblemLanguageResultExecution timeMemory
1148578adlinValley (BOI19_valley)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const int maxn = 1e5 + 5; int n,s,q,e,a[maxn],x[maxn],y[maxn],z[maxn],c[maxn],z1[maxn],z2[maxn]; vector <pair<int,int>> g[maxn]; ll d[maxn]; int xx; void dfs(int v, int u){ for(auto i : g[v]){ if(i.F == u) continue; if(min(i.F,v) == x[z1[xx]] && max(i.F,v) == y[z1[xx]]){ continue; } d[i.F] = d[v] + i.S; dfs(i.F,v); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s >> q >> e; for(int i = 1; i < n; i++){ cin >> x[i] >> y[i] >> z[i]; if(x[i] > y[i]) swap(x[i],y[i]); g[x[i]].pb({y[i],z[i]}); g[y[i]].pb({x[i],z[i]}); } for(int i = 1; i <= s; i++){ cin >> c[i]; } for(int i = 1; i <= q; i++){ cin >> z1[i] >> z2[i]; } if(n <= 1000 && q <= 1000){ for(int i = 1; i <= q; i++){ for(int j = 1; j <= n; j++) d[j] = -1; xx = i; d[z2[i]] = 0; dfs(z2[i],z2[i]); if(d[e] != -1){ cout << "escaped\n"; } else { int mn = 1e9; for(int j = 1; j <= s; j++){ if(d[c[j]] != -1) mn = min(mn, d[c[j]]); } if(mn == 1e9) cout << "oo\n"; else cout << mn << '\n'; } } } return 0; }

Compilation message (stderr)

valley.cpp: In function 'int main()':
valley.cpp:66:67: error: no matching function for call to 'min(int&, ll&)'
   66 |                                         if(d[c[j]] != -1) mn = min(mn, d[c[j]]);
      |                                                                ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from valley.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
valley.cpp:66:67: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   66 |                                         if(d[c[j]] != -1) mn = min(mn, d[c[j]]);
      |                                                                ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from valley.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
valley.cpp:66:67: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   66 |                                         if(d[c[j]] != -1) mn = min(mn, d[c[j]]);
      |                                                                ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from valley.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
valley.cpp:66:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |                                         if(d[c[j]] != -1) mn = min(mn, d[c[j]]);
      |                                                                ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from valley.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
valley.cpp:66:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |                                         if(d[c[j]] != -1) mn = min(mn, d[c[j]]);
      |                                                                ~~~^~~~~~~~~~~~~