# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
495138 | Ziel | Evacuation plan (IZhO18_plan) | C++17 | 502 ms | 19708 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* LES GREATEABLES BRO TEAM
**/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");
signed main() {
setIO();
int n, m;
cin >> n >> m;
vector<vector<pair<int, int>>> adj(n + 1);
for (int i = 0, x, y, z; i < m; i++) {
cin >> x >> y >> z;
adj[x].push_back({y, z});
adj[y].push_back({x, z});
}
int k;
cin >> k;
vector<int> g(k + 1), d(n + 1, 1e9 + 17);
for (int i = 1; i <= k; i++)
cin >> g[i];
{
set<pair<int, int>> q;
for (int i = 1; i <= k; i++) {
q.insert({0, g[i]});
d[g[i]] = 0;
}
while (sz(q)) {
int v = q.begin()->second;
q.erase(q.begin());
for (auto [to, len]: adj[v]) {
if (d[to] > d[v] + len) {
q.erase({d[to], to});
d[to] = d[v] + len;
q.insert({d[to], to});
}
}
}
}
int q;
cin >> q;
while (q--) {
int s, t;
cin >> s >> t;
cout << min(d[s], d[t]) << '\n';
}
return 0;
}
void setIO(const string &f) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen((f + ".in").c_str(), "r")) {
freopen((f + ".in").c_str(), "r", stdin);
freopen((f + ".out").c_str(), "w", stdout);
}
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |