# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
386344 |
2021-04-06T12:21:42 Z |
model_code |
Alias (COCI21_alias) |
C++17 |
|
1000 ms |
8300 KB |
#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 |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
492 KB |
Output is correct |
5 |
Correct |
817 ms |
6764 KB |
Output is correct |
6 |
Correct |
814 ms |
6768 KB |
Output is correct |
7 |
Execution timed out |
1094 ms |
8300 KB |
Time limit exceeded |