# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852902 | Anonymous_Guys | Commuter Pass (JOI18_commuter_pass) | C++17 | 101 ms | 16068 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ii pair<int, int>
#define ll long long
#define int long long
#define fi first
#define se second
#define fou(i, a, b) for (int i = a; i <= b; ++i)
#define all(v) (v).begin(), (v).end()
#define el '\n'
#define MASK(x) (1LL << (x))
#define BIT(mask, x) (((mask) >> (i)) & 1)
const int mxN = 1e5 + 9;
const int MOD =(int)1e9 + 7;
const int INF =(int)1e9;
int d[mxN];
vector<ii> adj[mxN];
void dijsktra(int s) {
memset(d, 0x3f, sizeof d);
d[s] = 0;
priority_queue<ii, vector<ii>, greater<ii> > q;
q.push({0, s});
while(!q.empty()) {
int u = q.top().se;
int kc = q.top().fi;
q.pop();
if (d[u] != kc) continue;
for (auto it : adj[u]) {
int v = it.fi;
int w = it.se;
if (d[v] > d[u] + w) {
d[v] = d[u] + w;
q.push({d[v], v});
}
}
}
}
signed main() {
if (fopen("GIAOPIZZA.INP", "r")) {
freopen("GIAOPIZZA.INP", "r", stdin);
freopen("GIAOPIZZA.OUT", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m ; cin >> n >> m;
int tram_S, tram_T; cin >> tram_S >> tram_T;
int tram_U, tram_V; cin >> tram_U >> tram_V;
fou(i, 1, m) {
int u, v, w; cin >> u >> v >> w;
adj[u].pb({v, w});
adj[v].pb({u, w});
}
dijsktra(tram_U);
cout << d[tram_V];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |