Submission #869376

#TimeUsernameProblemLanguageResultExecution timeMemory
869376vjudge1Commuter Pass (JOI18_commuter_pass)C++17
0 / 100
198 ms20820 KiB
//In His Name #include <bits/stdc++.h> using namespace std; #define ll long long #define int ll typedef pair<int, int> pii; typedef pair<long long, int> pli; typedef pair<long long, long long> pll; #define F first #define S second #define pb push_back #define bug(x) cout << "Ah shit , here we go again : " << x <<endl #define all(x) x.begin() , x.end() #define ceil(x,y) x/y + min(1ll,x%y) const int maxn = 2e5 + 10, MOD = 1e9 + 7; const ll INF = 1e18; int n , m , s , t , u , v ,par[maxn] , dis[maxn]; vector<pli> adj[maxn]; vector<int> path; void dijkstra(int root){ fill(dis , dis+n+1 , INF); dis[root] = 0; set<pli> st; st.insert({0,root}); while(!st.empty()){ int a = (*st.begin()).S; st.erase(st.begin()); for(pii i : adj[a]){ if(dis[i.S] > dis[a] + i.F){ st.erase({dis[i.S] , i.S}); dis[i.S] = dis[a] + i.F; st.insert({dis[i.S] , i.S}); par[i.S] = a; } } } } signed main(){ ios_base::sync_with_stdio(false); cin >> n >> m >> s >> t >> u >> v; for(int i = 1 ; i <= m ; i ++){ int a , b , w; cin >> a >> b >> w; adj[a].pb({w , b}); adj[b].pb({w , a}); } dijkstra(s); int x = t; while(x != par[s]){ path.pb(x); x = par[x]; } int ans = dis[v]; dijkstra(v); for(int i : path) ans = min(ans, dis[i]); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...