이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define int long long
#define INF 1000000000000000000
#define pii pair<long long, long long>
using namespace std;
struct DS{
int a, b, c;
};
signed main() {
int n, m, s, t, u, v;
cin >> n >> m >> s >> t >> u >> v;
vector<vector<pii> >G(n+1);
int a, b, c;
while (m--) {
cin >> a >> b >> c;
G[a].push_back({b, c});
G[b].push_back({a, c});
}
vector<int>sdis(n+5, INF), tdis(n+5, INF), vdis(n+5, INF);
sdis[s] = 0;
set<pii>q; q.insert({0, s});
//priority_queue<pii, vector<pii>, greater<pii> >q; q.push({0, s});
while (!q.empty()) {
auto t = *q.begin(); q.erase(q.begin());
int len = t.first, i = t.second;
//cout << i << " " << len << "\n";
if (len > sdis[i]) continue;
for (auto &j : G[i]) {
if (sdis[j.first] < len + j.second) continue;
if (sdis[j.first] != INF) {
q.erase({sdis[j.first], j.first});
}
sdis[j.first] = len + j.second;
q.insert({sdis[j.first], j.first});
}
}
cout << sdis[1] << "\n";
//for (int i = 1 ; i <= n ; i++) cout << sdis[i] << " ";
}
# | 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... |