Submission #647325

#TimeUsernameProblemLanguageResultExecution timeMemory
647325fatemetmhrCities (BOI16_cities)C++17
Compilation error
0 ms0 KiB
// ~ Be Name Khoda ~ // #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 1e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; vector <pair<int, int>> adj[maxn5]; ll dp[(1 << 5) + 1][maxn5]; int imp[maxn5], per[maxn5], cmpmask; inline bool cmp(int i, int j){return dp[cmpmask][i] < dp[cmpmask][j];} int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n, k, m; cin >> n >> k >> m; for(int i = 0; i < k; i++){ cin >> imp[i]; imp[i]--; } for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; a--; b--; if(a == b) continue; adj[a].pb({b, c}); adj[b].pb({a, c}); } for(int mask = 0; mask < (1 << k); mask++) for(int i = 0; i < n; i++) dp[mask][i] = inf; for(int i = 0; i < n; i++) dp[0][i] = 0; for(int i = 0; i < k; i++){ dp[1 << i][imp[i]] = 0; for(auto [u, w] : adj[imp[i]]) dp[1 << i][u] = min(dp[1 << i][u], w); } for(int i = 0; i < n; i++) per[i] = i; for(int mask = 0; mask < (1 << k); mask++){ cmpmask = mask; sort(per, per + n, cmp); for(int i = 0; i < n; i++){ int v = per[i]; int nmask = (1 << k) - 1 - mask; for(int sub = nmask; sub; sub = (sub - 1) & nmask){ dp[mask^sub][v] = min(dp[mask^sub][v], dp[mask][v] + dp[sub][v]); } for(auto [u, w] : adj[v]) dp[mask][u] = min(dp[mask][u], dp[mask][v] + w); } } ll ans = inf; for(int i = 0; i < n; i++) ans = min(ans, dp[(1 << k) - 1][i]); cout << ans << endl; }

Compilation message (stderr)

cities.cpp: In function 'int main()':
cities.cpp:55:49: error: no matching function for call to 'min(ll&, std::tuple_element<1, std::pair<int, int> >::type&)'
   55 |             dp[1 << i][u] = min(dp[1 << i][u], w);
      |                                                 ^
In file included 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 cities.cpp:3:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cities.cpp:55:49: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'})
   55 |             dp[1 << i][u] = min(dp[1 << i][u], w);
      |                                                 ^
In file included 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 cities.cpp:3:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cities.cpp:55:49: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'})
   55 |             dp[1 << i][u] = min(dp[1 << i][u], w);
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cities.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
cities.cpp:55:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |             dp[1 << i][u] = min(dp[1 << i][u], w);
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cities.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
cities.cpp:55:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |             dp[1 << i][u] = min(dp[1 << i][u], w);
      |                                                 ^