Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

const int INF=1000000000;

struct edge
{
    int w,u,v,res,dis;
    bool operator <(edge q)const
    {
     return v>q.v;
    }
};

map <string,int> stoi;
vector <edge> mp[3001];
bool lca[3001];
int dis[3001],res[1001],

index,cap;

void dijkstra(int srt)
{
    int i,u,v,w;
    edge now;
    for(i=0;i<index;i++){dis[i]=INF;res[i]=0;}
    priority_queue<edge> q;
    dis[srt]=0;res[i]=cap*10;
    for(i=0;i<mp[srt].size();i++)
        {
            mp[srt][i].res=cap*10;
            mp[srt][i].dis=0;
            q.push(mp[srt][i]);
        }
    while(!q.empty())
    {
       now=q.top();
       q.pop();
       u=now.u;
       v=now.v;
       w=now.w;
       //cout <<u<<" "<<v<<" "<<w<<" "<<now.dis<<" "<<now.res<<endl;
       //cout <<dis[v]<<" "<<res[v]<<endl;
       //system("pause");
       if(now.res-w<=res[v]&&now.dis+w>=dis[v])continue;
       if(now.res-w<0)continue;
       now.res-=w;
       now.dis+=w;
       if(now.dis<dis[v]){dis[v]=now.dis;res[v]=now.w;}
       if(lca[v])now.res=cap*10;
       for(i=0;i<mp[v].size();i++)
       {
         mp[v][i].res=now.res;
         mp[v][i].dis=now.dis;
         q.push(mp[v][i]);
       }
    }
}

int main()
{
    int n,m,w,i;
    edge ined;
    string srt,st,ed,dest;
    while(scanf("%d %d %d",&n,&m,&cap)!=EOF&&(n!=0||m!=0||cap!=0))
    {
        index=0;
        stoi.clear();
        for(i=0;i<n;i++)mp[i].clear();
        memset(lca,0,sizeof(lca));
        index=0;
        cin >>srt>>dest;
        if(stoi.find(srt)==stoi.end())stoi[srt]=index++;
        if(stoi.find(dest)==stoi.end())stoi[dest]=index++;
        for(i=0;i<n;i++)
        {
            cin >>st >>ed >>w;
            if(stoi.find(st)==stoi.end())stoi[st]=index++;
            if(stoi.find(ed)==stoi.end())stoi[ed]=index++;
            ined.u=stoi[st];
            ined.v=stoi[ed];
            ined.w=w;
            mp[stoi[st]].push_back(ined);
            swap(ined.u,ined.v);
            //cout <<ined.u<<" "<<ined.v<<endl;
            mp[stoi[ed]].push_back(ined);
        }
        for(i=0;i<m;i++)
        {
            cin >>st;
            lca[stoi[st]]=true;
        }
        dijkstra(stoi[srt]);
        if(dis[stoi[dest]]!=INF)printf("%d\n",dis[stoi[dest]]);
        else printf("-1\n");
    }
    return 0;
}

Compiler output:
a.cc:28:1: error: 'int index' redeclared as different kind of entity
   28 | index,cap;
      | ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:4:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void dijkstra(int)':
a.cc:34:14: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<'
   34 |     for(i=0;i<index;i++){dis[i]=INF;res[i]=0;}
      |             ~^~~~~~
a.cc: In function 'int main()':
a.cc:75:15: error: overloaded function with no contextual type information
   75 |         index=0;
      |               ^
a.cc:76:9: error: reference to 'stoi' is ambiguous
   76 |         stoi.clear();
      |         ^~~~
In file included from /usr/include/c++/14/string:54,
                 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,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:79:15: error: overloaded function with no contextual type information
   79 |         index=0;
      |               ^
a.cc:81:12: error: reference to 'stoi' is ambiguous
   81 |         if(stoi.find(srt)==stoi.end())stoi[srt]=index++;
      |            ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:81:28: error: reference to 'stoi' is ambiguous
   81 |         if(stoi.find(srt)==stoi.end())stoi[srt]=index++;
      |                            ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:81:39: error: reference to 'stoi' is ambiguous
   81 |         if(stoi.find(srt)==stoi.end())stoi[srt]=index++;
      |                                       ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:81:54: error: no post-increment operator for type
   81 |         if(stoi.find(srt)==stoi.end())stoi[srt]=index++;
      |                                                      ^~
a.cc:82:12: error: reference to 'stoi' is ambiguous
   82 |         if(stoi.find(dest)==stoi.end())stoi[dest]=index++;
      |            ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:82:29: error: reference to 'stoi' is ambiguous
   82 |         if(stoi.find(dest)==stoi.end())stoi[dest]=index++;
      |                             ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:82:40: error: reference to 'stoi' is ambiguous
   82 |         if(stoi.find(dest)==stoi.end())stoi[dest]=index++;
      |                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:82:56: error: no post-increment operator for type
   82 |         if(stoi.find(dest)==stoi.end())stoi[dest]=index++;
      |                                                        ^~
a.cc:86:16: error: reference to 'stoi' is ambiguous
   86 |             if(stoi.find(st)==stoi.end())stoi[st]=index++;
      |                ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:86:31: error: reference to 'stoi' is ambiguous
   86 |             if(stoi.find(st)==stoi.end())stoi[st]=index++;
      |                               ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:86:42: error: reference to 'stoi' is ambiguous
   86 |             if(stoi.find(st)==stoi.end())stoi[st]=index++;
      |                                          ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:86:56: error: no post-increment operator for type
   86 |             if(stoi.find(st)==stoi.end())stoi[st]=index++;
      |                                                        ^~
a.cc:87:16: error: reference to 'stoi' is ambiguous
   87 |             if(stoi.find(ed)==stoi.end())stoi[ed]=index++;
      |                ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note:                 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:23:18: note:                 'std::map<std::__cxx11::basic_string<char>, int> stoi'
   23 | map <string,int> stoi;
      |                  ^~~~
a.cc:87:31: error: reference to 'stoi' is ambiguous
   87 |             if(stoi.find(ed)==stoi.end())stoi[ed]=index++;
      |                               ^~~~