# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
517571 | kartel | Alias (COCI21_alias) | C++14 | 1074 ms | 592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define el "\n"
using namespace std;
typedef long long ll;
map <string, vector <pair <string, int> > > g;
string x, y;
int t, n, m;
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> x >> y >> t;
g[x].pb({y, t});
}
int q;
cin >> q;
while (q--) {
cin >> x >> y;
map <string, ll> d; d.clear();
d[x] = 0;
queue <string> q;
q.push(x);
while (q.size()) {
string v = q.front(); q.pop();
for (auto u : g[v]) {
if (!d.count(u.first) || d[u.first] > d[v] + u.second) {
d[u.first] = d[v] + u.second;
q.push(u.first);
}
}
}
if (d.count(y)) {
cout << d[y] << el;
} else {
cout << "Roger" << el;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |