Language: C++

#include <cstdio>
#include <cstring>
#include <map>
#include <iostream>
#include <string>
#include <queue>
#include <vector>

using namespace std;

struct edge{
	int t,c;
	edge(int tt=0,int cc=0){
		t=tt;
		c=cc;
	}
	bool operator<(const edge& e1)const{
		return c<e1.c;
	}
};

typedef edge data;

int n,m,cap;

vector<edge> G[7001];
vector<edge> GG[7001];
map<string,int> city;
int dp[7000];
bool flag[7000];

void make_path(int v){
	fill(dp,dp+city.size(),cap+1);
	priority_queue<data,vector<data>,greater<data> > que;
	que.push(data(v,0));
	dp[v]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.t]<q.c)continue;
		if(q.t!=v && flag[q.t]){
			GG[v].push_back(edge(q.t,q.c));
		}
		for(int i=0;i<G[q.t].size();i++){
			edge e=G[q.t][i];
			if(dp[e.t]>dp[q.t]+e.c){
				dp[e.t]=dp[q.t]+e.c;
				que.push(data(e.t,dp[e.t]));
			}
		}
	}
}

int dijk(int f,int t){
	memset(dp,-1,sizeof(dp));
	priority_queue<data,vector<data>,greater<data> > que;
	que.push(data(f,0));
	dp[f]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.t]<q.c)continue;
		if(q.t==t)return dp[q.t];
		for(int i=0;i<GG[q.t].size();i++){
			edge e=GG[q.t][i];
			if(dp[e.t]==-1 || dp[e.t]>dp[q.t]+e.c){
				dp[e.t]=dp[q.t]+e.c;
				que.push(data(e.t,dp[e.t]));
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&cap);
		if(n+m+cap==0)break;
		cap*=10;
		string s,g;
		cin >> s >> g;
		if(city.find(s)==city.end()){
			city.insert(map<string,int>::value_type(s,city.size()));
		}
		if(city.find(g)==city.end()){
			city.insert(map<string,int>::value_type(g,city.size()));
		}
		flag[city[s]]=true;
		flag[city[g]]=true;
		for(int i=0;i<n;i++){
			string f,t;
			int c;
			cin >> f >> t >> c;
			if(city.find(f)==city.end()){
				city.insert(map<string,int>::value_type(f,city.size()));
			}
			if(city.find(t)==city.end()){
				city.insert(map<string,int>::value_type(t,city.size()));
			}
			G[city[f]].push_back(edge(city[t],c));
			G[city[t]].push_back(edge(city[f],c));
		}
		for(int i=0;i<m;i++){
			string str;
			cin >> str;
			if(city.find(str)==city.end()){
				city.insert(map<string,int>::value_type(str,city.size()));
			}
			flag[city[str]]=true;

		}
		for(int i=0;i<=city.size();i++){
			if(flag[i])make_path(i);
		}
		printf("%d\n",dijk(city[s],city[g]));
		memset(flag,false,sizeof(flag));
		for(int i=0;i<=city.size();i++){
			G[i].clear();
			GG[i].clear();
		}
		city.clear();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void make_path(int)':
a.cc:34:40: error: template argument 1 is invalid
   34 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                        ^
a.cc:34:40: error: template argument 2 is invalid
a.cc:34:54: error: template argument 1 is invalid
   34 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                                      ^
a.cc:34:56: error: template argument 1 is invalid
   34 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                                        ^
a.cc:34:56: error: template argument 2 is invalid
a.cc:34:56: error: template argument 3 is invalid
a.cc:35:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   35 |         que.push(data(v,0));
      |             ^~~~
a.cc:35:18: error: reference to 'data' is ambiguous
   35 |         que.push(data(v,0));
      |                  ^~~~
In file included from /usr/include/c++/14/map:65,
                 from a.cc:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:22:14: note:                 'typedef struct edge data'
   22 | typedef edge data;
      |              ^~~~
a.cc:37:19: error: request for member 'size' in 'que', which is of non-class type 'int'
   37 |         while(que.size()){
      |                   ^~~~
a.cc:38:17: error: reference to 'data' is ambiguous
   38 |                 data q=que.top();
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:22:14: note:                 'typedef struct edge data'
   22 | typedef edge data;
      |              ^~~~
a.cc:39:21: error: request for member 'pop' in 'que', which is of non-class type 'int'
   39 |                 que.pop();
      |                     ^~~
a.cc:40:23: error: 'q' was not declared in this scope
   40 |                 if(dp[q.t]<q.c)continue;
      |                       ^
a.cc:41:20: error: 'q' was not declared in this scope
   41 |                 if(q.t!=v && flag[q.t]){
      |                    ^
a.cc:44:33: error: 'q' was not declared in this scope
   44 |                 for(int i=0;i<G[q.t].size();i++){
      |                                 ^
a.cc:48:37: error: request for member 'push' in 'que', which is of non-class type 'int'
   48 |                                 que.push(data(e.t,dp[e.t]));
      |                                     ^~~~
a.cc:48:42: error: reference to 'data' is ambiguous
   48 |                                 que.push(data(e.t,dp[e.t]));
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:22:14: note:                 'typedef struct edge data'
   22 | typedef edge data;
      |              ^~~~
a.cc: In function 'int dijk(int, int)':
a.cc:56:40: error: template argument 1 is invalid
   56 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                        ^
a.cc:56:40: error: template argument 2 is invalid
a.cc:56:54: error: template argument 1 is invalid
   56 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                                      ^
a.cc:56:56: error: template argument 1 is invalid
   56 |         priority_queue<data,vector<data>,greater<data> > que;
      |                                                        ^
a.cc:56:56: error: template argument 2 is invalid
a.cc:56:56: error: template argument 3 is invalid
a.cc:57:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   57 |         que.push(data(f,0));
      |             ^~~~
a.cc:57:18: error: reference to 'data' is ambiguous
   57 |         que.push(data(f,0));
      |                  ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:22:14: note:                 'typedef struct edge data'
   22 | typedef edge data;
      |              ^~~~
a.cc:59:19: error: request for member 'size' in 'que', which is of non-class type 'int'
   59 |         while(que.size()){
      |                   ^~~~
a.cc:60:17: error: reference to 'data' is ambiguous
   60 |                 data q=que.top();
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:22:14: note:                 'typedef struct edge data'
   22 | typedef edge data;
      |              ^~~~
a.cc:61:21: error: request for member 'pop' in 'que', which is of non-class type 'int'
   61 |                 que.pop();
      |                     ^~~
a.cc:62:23: error: 'q' was not declared in this scope
   62 |                 if(dp[q.t]<q.c)continue;
      |                       ^
a.cc:63:20: error: 'q' was not declared in this scope
   63 |                 if(q.t==t)return dp[q.t];
      |                    ^
a.cc:64:34: error: 'q' was not declared in this scope
   64 |                 for(int i=0;i<GG[q.t].size();i++){
      |                                  ^
a.cc:68:37: error: request for member 'push' in 'que', which is of non-class type 'int'
   68 |                                 que.push(data(e.t,dp[e.t]));
      |                                     ^~~~
a.cc:68:42: error: reference to 'data' is ambiguous
   68 |                                 que.push(data(e.t,dp[e.t]));
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_