Submission #924468

#TimeUsernameProblemLanguageResultExecution timeMemory
924468yeediotOlympic Bus (JOI20_ho_t4)C++14
0 / 100
12 ms1940 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define sz(x) (int)(x.size()) #define all(x) x.begin(),x.end() #define F first #define S second #define pb push_back #ifdef local void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);} #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else void setio(){} #define debug(x...) #endif struct edge{ int a,b,c,d; }; const int mxn=405; vector<edge>e; vector<pii>adj[mxn]; vector<int>temp; vector<int> dij(int st,int ed){ vector<int>dis(mxn); for(int i=0;i<mxn;i++)dis[i]=1e9; dis[st]=0; priority_queue<pii,vector<pii>,greater<pii>>pq; pq.push({0,st}); while(sz(pq)){ auto [d,v]=pq.top(); pq.pop(); if(dis[v]<d)continue; //cout<<v<<' '; for(auto [u,dd]:adj[v]){ if(dis[v]+dd<dis[u]){ dis[u]=dis[v]+dd; pq.push({dis[u],u}); } } } //for(int i=1;i<=8;i++)cout<<dis[i]<<' '; //cout<<'\n'; return dis; } signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); setio(); int n,m; cin>>n>>m; for(int i=0;i<m;i+=2){ int a,b,c,d; cin>>a>>b>>c>>d; int d2; cin>>a>>b>>c>>d2; d=min(d,d2); e.pb({a,b,c,d}); adj[a].pb({b,c}); } temp=dij(1,n); vector<int>temp2=dij(n,1); int ans=temp[n]+temp2[1]; for(auto [a,b,c,d]:e){ ans=min(ans,temp[b]+c+d+temp2[a]+temp2[1]); ans=min(ans,temp2[b]+c+d+temp[a]+temp[n]); ans=min(ans,temp[b]+c+d+temp2[a]+temp2[b]+c+d+temp[a]); } if(ans>=1e9){ cout<<-1<<'\n'; return 0; } cout<<ans<<'\n'; } /* */

Compilation message (stderr)

ho_t4.cpp: In function 'std::vector<long long int> dij(long long int, long long int)':
ho_t4.cpp:31:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |         auto [d,v]=pq.top();
      |              ^
ho_t4.cpp:35:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |         for(auto [u,dd]:adj[v]){
      |                  ^
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:64:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |     for(auto [a,b,c,d]:e){
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...