Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define sint(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

struct P{
    int cost;
    int node;
    int trans;
    bool operator<(const P& another) const {
        if(cost != another.cost){
            return cost > another.cost;
        }else{
            return trans < another.trans;
        }
    }
};

struct edge{
    int kind;
    int to;
    int cost;
    bool operator<(const edge& another) const {
        return cost < another.cost;
    }
};

const int MAX_N = 100005;

int d[MAX_N];
int tr[MAX_N];
int par[MAX_N];
vector<edge> G[MAX_N];
set<int> dup;
set<int> same[MAX_N];

void dijkstra(int s)
{
	priority_queue<P> que;
	d[s] = 0;
	que.push((P){0,s,0});
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.node;
		if(d[v] < p.cost) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
            int nptrans;
            if(par[v] > 0 && par[v] == par[G[v][i].to]){
                if(par[v] == 1 || par[v] == 2 || G[v][i].kind == 0){
                    nptrans = p.trans;
                }else{
                    nptrans = p.trans + 1;
                }
            }else{
                nptrans = p.trans;
            }
			if(d[G[v][i].to] > d[v] + G[v][i].cost){
				d[G[v][i].to] = d[v] + G[v][i].cost;
                tr[G[v][i].to] = nptrans;
				que.push((P){d[G[v][i].to],G[v][i].to,tr[G[v][i].to]});
			}else if(d[G[v][i].to] == d[v] + G[v][i].cost && tr[G[v][i].to] > nptrans){
                tr[G[v][i].to] = nptrans;
                que.push((P){d[G[v][i].to],G[v][i].to,tr[G[v][i].to]});
            }
		}
	}
}


int main()
{
    int n,t;
    int cnt = 1;
    map<string,int> mp;
	cin >> n >> t;
	string s1,s2;
    cin >> s1 >> s2;
    mp[s1] = cnt++,mp[s2] = cnt++;
    rep(i,n){
        int a;
        cin >> a;
        vector<int> vec(a);
        rep(j,a){
            string s;
            cin >> s;
            if(mp[s] == 0){
                vec[j] = cnt;
                mp[s] = cnt++;
            }else{
                dup.insert(mp[s]);
                same[mp[s]].insert(cnt);
                vec[j] = cnt++;
            }
        }
        rep(j,a-1){
            int tm;
            cin >> tm;
            G[vec[j]].push_back((edge){0,vec[j+1],tm});
            G[vec[j+1]].push_back((edge){0,vec[j],tm});
        }
    }
    each(it,dup){
        same[it].insert(it);
    }
    each(it1,same[1]){
        each(it2,same[1]){
            if(it1 != it2){
                G[it1].push_back((edge){1,it2,0});
                G[it2].push_back((edge){1,it1,0});
            }
        }
    }
    each(it1,same[2]){
        each(it2,same[2]){
            if(it1 != it2){
                G[it1].push_back((edge){1,it2,0});
                G[it2].push_back((edge){1,it1,0});
            }
        }
    }
    each(it,dup){
        if(it != 1 || it != 2){
            each(it1,same[it]){
                each(it2,same[it]){
                    if(it1 != it2){
                        G[it1].pb((edge){1,it2,t});
                        G[it2].pb((edge){1,it1,t});
                    }
                }
            }
        }
    }
    // rep(i,cnt){
    //     rep(j,G[i].size()){
    //         cout << i << " " << G[i][j].to << " " << G[i][j].cost << "\n";
    //     }
    // }
    rep(i,cnt){
        par[i] = -1;
    }
    each(it,dup){
        each(it1,same[it]){
            par[it1] = it;
        }
    }
    fill(d,d+cnt,INF);
    fill(tr,tr+cnt,INF);
    dijkstra(1);
    // rep(i,cnt){
    //     cout << i << " " << d[i] << " " << tr[i] << "\n";
    // }
    if(d[2] >= INF){
        cout << "-1\n";
    }else{
        cout << d[2] << " " << tr[2] << "\n";
    }
	return 0;
}

Compiler output:
a.cc:47:10: error: 'std::set<int> dup' redeclared as different kind of entity
   47 | set<int> dup;
      |          ^~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:552:12: note: previous declaration 'int dup(int)'
  552 | extern int dup (int __fd) __THROW __wur;
      |            ^~~
a.cc: In function 'int main()':
a.cc:105:21: error: request for member 'insert' in 'dup', which is of non-class type 'int(int) noexcept'
  105 |                 dup.insert(mp[s]);
      |                     ^~~~~~
a.cc:7:36: error: 'begin' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:117:5: note: in expansion of macro 'each'
  117 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:117:5: note: in expansion of macro 'each'
  117 |     each(it,dup){
      |     ^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:7:36: error: 'end' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:117:5: note: in expansion of macro 'each'
  117 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:117:5: note: in expansion of macro 'each'
  117 |     each(it,dup){
      |     ^~~~
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:7:36: error: 'begin' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:136:5: note: in expansion of macro 'each'
  136 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:136:5: note: in expansion of macro 'each'
  136 |     each(it,dup){
      |     ^~~~
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:7:36: error: 'end' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:136:5: note: in expansion of macro 'each'
  136 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:136:5: note: in expansion of macro 'each'
  136 |     each(it,dup){
      |     ^~~~
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:7:36: error: 'begin' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:156:5: note: in expansion of macro 'each'
  156 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:156:5: note: in expansion of macro 'each'
  156 |     each(it,dup){
      |     ^~~~
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:7:36: error: 'end' was not declared in this scope
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:156:5: note: in expansion of macro 'each'
  156 |     each(it,dup){
      |     ^~~~
a.cc:7:36: note: suggested alternatives:
    7 | #define each(a, b) for(auto (a): (b))
      |                                    ^
a.cc:156:5: note: in expansion of macro 'each'
  156 |     each(it,dup){
      |     ^~~~
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~