# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
517571 | kartel | Alias (COCI21_alias) | C++14 | 1074 ms | 592 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>
#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... |