Language: C++

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

typedef pair<string,int> P;
int n,q,m;
vector<P> v[11];
vector<string> name;
int root[11][11];
const int INF=100000000;
int dpc[11][1<<11];
int dpd[11][1<<11];
int ac;
int ad;

void rec(int x,int bit,int c,int d){
	if(dpc[x][bit]<c)return;
	if(dpc[x][bit]==c && dpd[x][bit]<d)return;
	if(bit==(1<<n)-1){
		if(c<ac || (c==ac && d<ad)){
			ac=c;
			ad=d;
		}
	}
	else{
		for(int i=0;i<v[x].size;i++){
			for(int j=0;j<name.size;j++){
				if(name[j]==v[x][i].first && !(bit >> j & 1)){
					int nbit |= 1<<j;
					int nc=c+v[x][i].second;
					if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){
						dpc[x][nbit]=vc;
						dpd[x][nbit]=d;
						rec(x,nbit,vc,d);
					}
				}
			}
		}
		for(int i=0;i<=n;i++){
			int nd=d+root[i][x];
			if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){
				dpc[x][nbit]=c;
				dpd[x][nbit]=vd;
				rec(i,bit,c,nd);
			}
		}
	}
}


int main(void){
	while(1){
		ac=INF;
		ad=INF;
		for(int i=0;i<=10;i++){
			for(int j=0;j<=10;j++){
				root[i][j]=INF;
			}
			root[i][i]=0;
		}
		for(int i=0;i<11;i++){
			v[i].clear();
		}
		name.clear();
		cin >> n;
		for(int i=1;i<=n;i++){
			int k;
			cin >> k;
			for(int j=0;j<k;j++){
				string str;
				int cost;
				cin >> str >> cost;
				v[i].push_back(P(str,cost));
			}
		}
		cin >> q;
		for(int i=0;i<q;i++){
			string str;
			cin >> str;
			name.push_back(str);
		}
		cin >> m;
		for(int i=0;i<m;i++){
			int s,t,d;
			cin >> s >> t >> d;
			root[s][t]=min(d,root[s][t]);
			root[t][s]=min(d,root[t][s]);
		}
		for(int k=0;k<=n;k++){
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++){
					root[i][j]=min(root[i][j],root[i][k]+root[k][j]);
				}
			}
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<=(1<<n)-1;j++){
				dp[i][j]=INF;
			}
		}
		rec(0,0,0,0);
		if(ac==INF)cout << "impossible" << endl;
		else cout << ac << " " << ad << endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int, int, int)':
a.cc:49:36: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<std::__cxx11::basic_string<char>, int>; _Alloc = std::allocator<std::pair<std::__cxx11::basic_string<char>, int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   49 |                 for(int i=0;i<v[x].size;i++){
      |                               ~~~~~^~~~
      |                                        ()
a.cc:50:44: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; size_type = long unsigned int]' (did you forget the '()' ?)
   50 |                         for(int j=0;j<name.size;j++){
      |                                       ~~~~~^~~~
      |                                                ()
a.cc:52:50: error: expected initializer before '|=' token
   52 |                                         int nbit |= 1<<j;
      |                                                  ^~
a.cc:54:51: error: 'nbit' was not declared in this scope; did you mean 'bit'?
   54 |                                         if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){
      |                                                   ^~~~
      |                                                   bit
a.cc:54:57: error: 'vc' was not declared in this scope; did you mean 'nc'?
   54 |                                         if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){
      |                                                         ^~
      |                                                         nc
a.cc:64:79: error: expected ')' before '{' token
   64 |                         if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){
      |                           ~                                                   ^
      |                                                                               )
a.cc:69:17: error: expected primary-expression before '}' token
   69 |                 }
      |                 ^
a.cc: In function 'int main()':
a.cc:121:33: error: 'dp' was not declared in this scope; did you mean 'dpd'?
  121 |                                 dp[i][j]=INF;
      |                                 ^~
      |                                 dpd