# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
948529 | 2024-03-18T07:40:16 Z | phone64bit | Commuter Pass (JOI18_commuter_pass) | C++14 | 119 ms | 25156 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN = 1e5+10; struct Q { int src; ll w; bool operator < (const Q&rhs) const { return w>rhs.w; } }; struct path { int dest; ll w; }; struct edge { int u, v; }; vector<edge> k_path, tmp_path; vector<path> edges[mxN]; bitset<mxN> vs; ll dp[mxN], k_dp[mxN], ans = 1e18; int n,m,s,t,u,v; priority_queue<Q> pq; void dfs(int u) { vs[u]=1; if(u==t&&k_path.size()<tmp_path.size()) { k_path = tmp_path; return; } for(auto v: edges[u]) if(!vs[v.dest]) vs[v.dest]=1, tmp_path.push_back({u, v.dest}), dfs(v.dest), tmp_path.pop_back(); } int main() { for(int i=0; i<mxN; i++) dp[i]=1e18; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v); while(m--) { int u, v; ll w; scanf("%d%d%lld", &u, &v, &w); edges[u].push_back({v, w}); edges[v].push_back({u, w}); } dfs(s); for(auto x: k_path) edges[x.u].push_back({x.v, 0}), edges[x.v].push_back({x.u, 0}); dp[u] = 0; pq.push({u, 0}); while(!pq.empty()) { auto [src, w] = pq.top(); pq.pop(); if(src==v) { ans=w; break; } for(auto v: edges[src]) { if(dp[v.dest]>w+v.w) { dp[v.dest]=w+v.w; pq.push({v.dest, dp[v.dest]}); } } } printf("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 106 ms | 25156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 119 ms | 24656 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5468 KB | Output is correct |
2 | Correct | 1 ms | 4188 KB | Output is correct |
3 | Incorrect | 2 ms | 4188 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 106 ms | 25156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |