# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734606 | rahidilbayramli | Alias (COCI21_alias) | C++17 | 1028 ms | 8552 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 ll long long
#define vl vector<ll>
#define sl set<ll>
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define tests while(t--)
using namespace std;
const ll sz = 1010;
vector<vector<ll>>graph(sz, vector<ll>(sz, 1e15));
ll n, m, i, j;
int main()
{
set<string>st;
map<string, ll>mp;
string a, b;
ll n, m, i, j, k, l, c, x, y, q;
cin >> n >> m;
for(i = 0; i < m; i++)
{
cin >> a >> b >> c;
l = st.size();
st.insert(a);
if(st.size() != l) mp[a] = st.size();
l = st.size();
st.insert(b);
if(st.size() != l) mp[b] = st.size();
x = mp[a];
y = mp[b];
c = min(c, graph[x][y]);
graph[x][y] = c;
}
for(i = 1; i <= n; i++) graph[i][i] = 0;
for(k = 1; k <= n; k++)
{
for(i = 1; i <= n; i++)
{
for(j = 1; j <= n; j++)
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
}
}
cin >> q;
while(q--)
{
cin >> a >> b;
x = mp[a], y = mp[b];
if(graph[x][y] == 1e15) cout << "Roger\n";
else cout << graph[x][y] << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |