Submission #888198

# Submission time Handle Problem Language Result Execution time Memory
888198 2023-12-16T10:35:59 Z Unforgettablepl 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 INF = 1e15;

struct edge{
    int first,second,d;
};

vector<edge> adj[201];
bool visited[201];
int n;

struct comp{
    bool operator()(pair<int,int> a,pair<int,int> b){
        return a.second==b.second ? a.first>b.first : a.second>b.second;
    }
};

int dijkastra(){
    priority_queue<pair<int,int>,vector<pair<int,int>>,comp> q;
    int c = INF;
    for(int i=1;i<=n;i++)visited[i]=false;
    q.emplace(1,0);
    while(!q.empty()){
        auto curr = q.top();q.pop();
        if(visited[curr.first])continue;
        visited[curr.first]=true;
        if(curr.first==n){
            c = curr.second;
            break;
        }
        for(auto&x:adj[curr.first])if(!visited[x.first])q.emplace(x.first,x.second+curr.second);
    }
    for(int i=1;i<=n;i++)visited[i]=false;
    q.emplace(n,0);
    while(!q.empty()){
        auto curr = q.top();q.pop();
        if(visited[curr.first])continue;
        visited[curr.first]=true;
        if(curr.first==1){
            c += curr.second;
            break;
        }
        for(auto&x:adj[curr.first])if(!visited[x.first])q.emplace(x.first,x.second+curr.second);
    }
    return c;
}

int32_t main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a,b,c,d;cin>>a>>b>>c>>d;
        adj[a].emplace_back(b,c,d);
    }
    int ans = dijkastra();
    for(int i=1;i<=n;i++){
        for(auto&x:adj[i]){
            adj[x.first].emplace_back(i,x.second,x.d);
            x.second=INF;
            ans = min(ans,dijkastra()+x.d);
            x.second=adj[x.first].back().second;
            adj[x.first].back().second=INF;
        }
    }
    cout << (ans>=INF ? -1 : ans) << '\n';
}

Compilation message

In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 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 ho_t4.cpp:1:
/usr/include/c++/10/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = edge; _Args = {long long int&, long long int&, long long int&}; _Tp = edge]':
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = edge; _Args = {long long int&, long long int&, long long int&}; _Tp = edge; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<edge>]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::reference = edge&]'
ho_t4.cpp:58:34:   required from here
/usr/include/c++/10/ext/new_allocator.h:150:4: error: new initializer expression list treated as compound expression [-fpermissive]
  150 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/ext/new_allocator.h:150:4: error: no matching function for call to 'edge::edge(long long int&)'
ho_t4.cpp:7:8: note: candidate: 'edge::edge()'
    7 | struct edge{
      |        ^~~~
ho_t4.cpp:7:8: note:   candidate expects 0 arguments, 1 provided
ho_t4.cpp:7:8: note: candidate: 'constexpr edge::edge(const edge&)'
ho_t4.cpp:7:8: note:   no known conversion for argument 1 from 'long long int' to 'const edge&'
ho_t4.cpp:7:8: note: candidate: 'constexpr edge::edge(edge&&)'
ho_t4.cpp:7:8: note:   no known conversion for argument 1 from 'long long int' to 'edge&&'