# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386344 | model_code | Alias (COCI21_alias) | C++17 | 1094 ms | 8300 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;
typedef long long ll;
const ll INF = 1e18;
vector<string> words;
int index(string word) {
for (int i = 0; i < (int)words.size(); i++)
if (words[i] == word) return i;
words.push_back(word);
return (int)words.size() - 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vector<vector<ll>> dist(n, vector<ll>(n, INF));
for (int i = 0; i < n; i++) dist[i][i] = 0;
while (m--) {
string x, y;
ll t;
cin >> x >> y >> t;
dist[index(x)][index(y)] = min(dist[index(x)][index(y)], t);
}
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
int q;
cin >> q;
while (q--) {
string a, b;
cin >> a >> b;
ll sol = dist[index(a)][index(b)];
if (sol == INF) cout << "Roger\n";
else cout << sol << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |