Language: C++

#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#include <utility>

using namespace std;

#define PI acos(-1.0)
#define EPS 1e-6
#define LGE 0.434294481903//log10(e)
#define lll __int64
#define ll long long
#define INF 0x7fffffff
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)

typedef pair<int,int> pii;
const int N=6002;
const int N2=6002;
int node_num,edge_num,start_node,final_node;
int gap_num,cap;
int node_first[N],node_next[N2],node_begin[N2],node_end[N2],node_value[N2];
int distance_[N],gap[N];
priority_queue<pii,vector<pii>,greater<pii> > pq;
struct jcc
{
    char cc[20];
    bool operator < (const jcc& a) const
    {
        return strcmp(cc,a.cc)==1;//莉主、ァ蛻ー蟆?    }
}ctm;

map<jcc,int> ma;
map<jcc,int>::iterator it;
bool ggap[N];

void dijkstra();

int main()
{
    //freopen("D:\\input.in","r",stdin);
    //freopen("D:\\output.out","w",stdout);
    while(scanf("%d%d%d",&edge_num,&gap_num,&cap)&&(edge_num||gap_num||cap)){
        ma.clear();
    start_node=1;
    final_node=2;

    int tj0=1;
    scanf("%s",ctm.cc);
    ma.insert(pair<jcc,int>(ctm,tj0++));
    scanf("%s",ctm.cc);
    ma.insert(pair<jcc,int>(ctm,tj0++));
    node_num=edge_num*2;
    rep(i,1,node_num)
    {

        node_first[i]=-1;
    }
    int t1,t2,t3;
    rep(i,1,edge_num)
    {
        scanf("%s",ctm.cc);
        it=ma.find(ctm);
        if(it!=ma.end())
        {
            t1=(*it).second;
        }
        else
        {
            t1=tj0;
            ma.insert(pair<jcc,int>(ctm,tj0++));
        }
        scanf("%s",ctm.cc);
        it=ma.find(ctm);
        if(it!=ma.end())
        {
            t2=(*it).second;
        }
        else
        {
            t2=tj0;
            ma.insert(pair<jcc,int>(ctm,tj0++));
        }
        scanf("%d",&t3);
        node_begin[i]=t1;
        node_end[i]=t2;
        node_value[i]=t3;
        node_next[i]=node_first[node_begin[i]];
        node_first[node_begin[i]]=i;
        node_begin[i+edge_num]=node_end[i];
        node_end[i+edge_num]=node_begin[i];
        node_value[i+edge_num]=node_value[i];
        node_next[i+edge_num]=node_first[node_begin[i+edge_num]];
        node_first[node_begin[i+edge_num]]=i+edge_num;
    }
    node_num=tj0-1;
    rep(i,1,node_num)
        ggap[i]=0;
    rep(i,1,gap_num)
    {
        scanf("%s",ctm.cc);
        it=ma.find(ctm);
        ggap[(*it).second]=1;
    }
    dijkstra();
    if(distance_[final_node]==INF)  puts("-1");
    else
    printf("%d\n",distance_[final_node]);
    }
    return 0;
}
void dijkstra()
{
    rep(i,1,node_num)   distance_[i]=INF;
    distance_[start_node]=0;
    rep(i,1,node_num)
        gap[i]=0;
    gap[start_node]=cap;
    pq.push(make_pair(distance_[start_node],start_node));
    while(!pq.empty())
    {
        pii pi=pq.top();
        int x=pi.second;
        pq.pop();
        if(pi.first!=distance_[x]) continue;
        for(int i=node_first[x];i!=-1;i=node_next[i])
        {
            if(gap[x]*10>=node_value[i]&&distance_[node_end[i]]>distance_[x]+node_value[i])
            {
                distance_[node_end[i]]=distance_[x]+node_value[i];
                pq.push(make_pair(distance_[node_end[i]],node_end[i]));
                if(ggap[node_end[i]]==0) gap[node_end[i]]=max(gap[node_end[i]],gap[x]*10-node_value[i])/10;
                else    gap[node_end[i]]=cap;
            }
        }
    }
}

Compiler output:
a.cc:52:2: error: 'ctm' does not name a type; did you mean 'tm'?
   52 | }ctm;
      |  ^~~
      |  tm
a.cc:133:6: error: 'void jcc::dijkstra()' cannot be overloaded with 'void jcc::dijkstra()'
  133 | void dijkstra()
      |      ^~~~~~~~
a.cc:58:6: note: previous declaration 'void jcc::dijkstra()'
   58 | void dijkstra();
      |      ^~~~~~~~
a.cc:158:2: error: expected '}' at end of input
  158 | }
      |  ^
a.cc:47:1: note: to match this '{'
   47 | {
      | ^
a.cc: In member function 'int jcc::main()':
a.cc:70:16: error: 'ctm' was not declared in this scope; did you mean 'tm'?
   70 |     scanf("%s",ctm.cc);
      |                ^~~
      |                tm
a.cc: At global scope:
a.cc:158:2: error: expected unqualified-id at end of input
  158 | }
      |  ^