| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 471659 | LeeRise | Alias (COCI21_alias) | C++14 | 26 ms | 464 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 faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fi first
#define se second
using namespace std;
const int maxn=1005;
const int oo=1e18;
int tam=0;
map<string,int> id;
vector<pair<int,int>> e[maxn];
long long memo[maxn];
int getid(string x)
{
	if(id.find(x)==id.end())
		id[x]=++tam;
	return id[x];
}
void dijkstra(int x)
{
	priority_queue<pair<long long,int>> pq;
	memo[x]=0;
	pq.emplace(0,x);
	while(!pq.empty())
	{
		auto [dd,y]=pq.top();
		pq.pop();
		if(memo[y]!=-dd)
			continue;
		for(auto [v,c]:e[y])
		{
			if(memo[v]>memo[y]+c)
			{
				memo[v]=memo[y]+c;
				pq.emplace(-memo[v],v);
			}
		}
	}
	return;
}
int main()
{
	faster
	//freopen("ALIAS.INP", "r", stdin);
	//freopen("ALIAS.OUT", "w", stdout);
	int n,m,q;
	cin >> n >> m;
	for(int i=1;i<=m;i++)
	{
		string a,b;
		int c;
		cin >> a >> b >> c;
		e[getid(a)].emplace_back(getid(b),c);
	}
	cin>>q;
	while(q--)
	{
		string a,b;
		cin >> a >> b;
		for(int i=1;i<=n;i++)
			memo[i]=oo;
        int x, y;
        x=getid(a);
        y=getid(b);
		dijkstra(x);
		if(memo[y]==oo)
			cout<<"Roger" << endl;
		else
			cout<< memo[y]<< endl;
	}
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
