Submission #535327

#TimeUsernameProblemLanguageResultExecution timeMemory
535327BiazOlympic Bus (JOI20_ho_t4)C++17
0 / 100
1087 ms3668 KiB
#include<bits/stdc++.h> //#define int long long #define pb push_back #define ALL(x) x.begin(),x.end() #define fi first #define se second #define ist insert using namespace std; int min(int a,int b){return a<b?a:b;} int max(int a,int b){return a>b?a:b;} typedef long long ll; typedef pair<ll,ll> pii; const int N=205; const int MOD=1000000007;//998244353 const int INF=1700000000000000000;//2147483647; int n,m; struct I{ int u,v,c,D,id; } ee[50005]; vector<pii> e[N]; priority_queue<pii,vector<pii>,greater<pii>> pq; int d[N]; int dij(int s,int t){ memset(d,0x3f,sizeof(d)); d[s]=0; pq.push({0,s}); while (pq.size()){ int v=pq.top().se,w=pq.top().fi;pq.pop(); if (d[v]<w) continue; for (pii i:e[v]) if(d[i.fi]>w+i.se){ d[i.fi]=w+i.se; pq.push({d[i.fi],i.fi}); } } return d[t]; } inline void sol(){ cin >>n>>m; for (int i=0;i<m;i++){ cin >>ee[i].u>>ee[i].v>>ee[i].c>>ee[i].D; } int ans=INF; for (int kk=0;kk<=m;kk++){ for (int i=1;i<=n;i++) e[i].clear(); int cst=0; for (int i=0;i<m;i++){ if (i==kk) e[ee[i].v].pb({ee[i].u,ee[i].c}),cst=ee[i].D; else e[ee[i].u].pb({ee[i].v,ee[i].c}); } ans=min(ans,dij(1,n)+dij(n,1)+cst); } cout <<ans<<'\n'; } signed main(){ int _=1; //cin >>_; while (_--) sol(); return 0; }

Compilation message (stderr)

ho_t4.cpp:15:15: warning: overflow in conversion from 'long int' to 'int' changes value from '1700000000000000000' to '908722176' [-Woverflow]
   15 | const int INF=1700000000000000000;//2147483647;
      |               ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...