Submission #956254

# Submission time Handle Problem Language Result Execution time Memory
956254 2024-04-01T12:13:46 Z samvar_0907 Olympic Bus (JOI20_ho_t4) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
const int N = 201, M = 40001;
 
int n, m;
 
multiset<pair<int, int>> adj[N];
int c[M], d[M];
pair<int, int> edges[M];

vector<int> dijkstra(int source){
    vector<int> dist(n + 1, 1e15);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push({0, source});
    dist[source] = 0;
    while (!pq.empty()) {
        int u = pq.top().second;
        int d = pq.top().first;
        pq.pop();
        for (auto &n : adj[u]){
            if (dist[n.first] > d + c[n.second]){
                dist[n.first] = d + c[n.second];
                pq.push({dist[n.first], n.first});
            }
        }
    }
    return dist;
}
 
signed main(){
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        adj[i].clear();
    }
    vector<vector<int>> dist(n + 1, vector<int>(n + 1, 1e15));
    for (int i = 1; i <= n; ++i) {
        dist[i][i] = 0;
    }
    
    for (int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v >> c[i] >> d[i];
        adj[u].insert({v, i});
        edges[i] = {u, v};
        dist[u][v] = min(dist[u][v], c[i]);
    }

    // Floyd Warshall
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = min((int)1e15), dist[1][n] + dist[n][1]);
    for (int i = 0; i < m; ++i) {

        int u = edges[i].first, v = edges[i].second;

        if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) + 
            min(dist[n][1], dist[n][v] + c[i] + dist[u][1]) + d[i] < ans) {

                adj[u].erase(adj[u].find({v, i}));
                adj[v].insert({u, i});
                ans = min(ans, d[i] + dijkstra(1)[n] + dijkstra(n)[1]);
                adj[v].erase(adj[v].find({edges[i].first, i}));
                adj[u].insert({v, i});
            }
    }
    if (ans == (int)(1e15)) {
        ans = -1;
    }
    cout << ans;
}

Compilation message

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:60:28: error: no matching function for call to 'min(long long int)'
   60 |     int ans = min((int)1e15), dist[1][n] + dist[n][1]);
      |                            ^
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 ho_t4.cpp:1:
/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:
ho_t4.cpp:60:28: note:   candidate expects 2 arguments, 1 provided
   60 |     int ans = min((int)1e15), dist[1][n] + dist[n][1]);
      |                            ^
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 ho_t4.cpp:1:
/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:
ho_t4.cpp:60:28: note:   candidate expects 3 arguments, 1 provided
   60 |     int ans = min((int)1e15), dist[1][n] + dist[n][1]);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/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:
ho_t4.cpp:60:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     int ans = min((int)1e15), dist[1][n] + dist[n][1]);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/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:
ho_t4.cpp:60:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     int ans = min((int)1e15), dist[1][n] + dist[n][1]);
      |                            ^