Language: C++

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#define INF 1000000007
#define MAX_V 3030
typedef long long ll;

using namespace std;
struct edge{int to, cost;};
typedef pair < int, int> P;//first 譛?洒霍晉ヲサ second鬘カ轤ケ郛門捷
int V, VV, N, M, cap;
vector <edge> G[MAX_V],  GG[303];
int d[MAX_V];
map <int, int> m;
void add_edge1(int x, int y, int k)
{
	edge te;
	te.to = y;
	te.cost = k;
	G[x].push_back(te);
	te.to = x;
	G[y].push_back(te);
}

void add_edge2(int x, int y, int k)
{
	edge te;
	te.to = y;
	te.cost = k;
	GG[x].push_back(te);
	te.to = x;
	GG[y].push_back(te);
}
void dijkstra1(int s)
{
	priority_queue <P, vector <P>, greater <P> > q;
	fill(d, d + V, INF);
	d[s] = 0;
	q.push(P(0, s));

	while(!q.empty())
	{
		P p = q.top();
		q.pop();
		int v = p.second;
		if(d[v] < p.first)
			continue;
		for(int i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
}
void dijkstra2(int s)
{
	priority_queue <P, vector<P>, greater <P> > q;
	fill(d, d + V, INF);
	d[s] = 0;
	q.push(P(0, s));

	while(!q.empty())
	{
		P p = q.top();
		q.pop();
		int v = p.second;
		if(d[v] < p.first)
			continue;
		for(int i = 0; i < GG[v].size(); i++)
		{
			edge e = GG[v][i];
			if(d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
}
int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	int i, j;
	while(1)
	{
		scanf("%d%d%d", &N, &M, &cap);
		if(N == 0 && M == 0 && cap == 0)
			return 0;
		for(i = 0; i < MAX_V; i++)
		if(!G[i].empty())
			G[i].clear();
		for(i = 0; i < 303; i++)
		if(!GG[i].empty())
			GG[i].clear();
		map <string, int> ma;
		cap *= 10;
		string a, b;
		int k;
		V = 0;
		cin >> a >> b;
		ma[a] = V++;
		ma[b] = V++;
		for(i = 0; i < N; i++)
		{
			cin >> a >> b >> k;
			if(ma.find(a) == ma.end())
				ma[a] = V++;
			if(ma.find(b) == ma.end())
				ma[b] = V++;
			if(k <= cap)
			{
				add_edge1(ma[a], ma[b], k);
			}
		}
		m[0] = 0;
		m[1] = 1;
		for(i = 0; i < M; i++)
		{
			cin >> a;
			if(ma.find(a) != m.end())
				m[i + 2] = ma[a];
		}
		VV = m.size();
		for(i = 0; i < VV; i++)
		{
			dijkstra1(m[i]);
			for(j = 0; j < VV; j++)
			{
				if(d[m[j]] <= cap)
				{
					add_edge2(i, j, d[m[j]]);
				}
			}
		}
		dijkstra2(0);
		if(d[1] == INF)
			d[1] = -1;
		printf("%d\n", d[1]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:132:39: error: no match for 'operator!=' (operand types are 'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} and 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'})
  132 |                         if(ma.find(a) != m.end())
      |                            ~~~~~~~~~~ ^~ ~~~~~~~
      |                                   |           |
      |                                   |           _Rb_tree_iterator<pair<const int,[...]>>
      |                                   _Rb_tree_iterator<pair<const std::__cxx11::basic_string<char>,[...]>>
In file included from /usr/include/c++/14/iosfwd:42,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
  197 |     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::fpos<_StateT>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
  243 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::allocator<_CharT>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  500 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1686 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1753 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1052 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
  651 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
/usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
  658 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  132 |                         if(ma.find(a) != m.end())
      |                                                ^
/usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
  666 |     operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:666:5: note:   template argument deduction/substitution failed:
a.cc:132:48: note:   'std::_Rb_tree_iterator<std::pai