Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

ll n;
vector<vector<ll>> g;
vector<ll> power;
vector<ll> used;
vector<P> ord;

void build_graph() {
	map<string,ll> dict;
	ll cnt = 0;
	REP(i,n) {
		string a; ll b, c;
		cin >> a >> b >> c;
		if(dict.count(a) == 0) {
			dict[a] = cnt;
			cnt++;
		}
		ll p = dict[a];
		power[dict[a]] = b;
		REP(j,c) {
			string t;
			cin >> t;
			if(dict.count(t) == 0) {
				dict[t] = cnt;
				cnt++;
			}
			g[p].pb(dict[t]);
		}
	}
}

ll dfs(ll idx, ll sum) {
	if(idx == n) return sum;
	if(used[ord[idx].second] != -1) return dfs(idx + 1, sum);
	ll ret = 0;
	vector<ll> tmp(n);
	REP(i,n) tmp[i] = used[i];
	if((ll)g[ord[idx].second].size() > 1) {
		used[ord[idx].second] = 0;
		ret = max(ret, dfs(idx + 1, sum));
	}
	used[ord[idx].second] = 1;
	REP(i,g[ord[idx].second].size()) used[g[ord[idx].second][i]] = 0;
	ret = max(ret, dfs(idx + 1, sum + power[ord[idx].second]));
	REP(i,n) used[i] = tmp[i];
	return ret;
}

ll solve() {
	power.assign(n,0);
	used.assign(n, -1);
	ord.assign(n,-1);
	g.assign(n,vector<ll>(0)); build_graph();
	ll sum = 0;
	REP(i,n) if(used[i] == -1) {
		if(i == 0) {
			used[i] = 1;
			REP(j,g[i].size()) used[g[i][j]] = 0;
			sum += power[i];
			continue;	
		}
		if(g[i].size() == 0) {
			used[i] = 1;
			sum += power[i];
		}
		if(g[i].size() == 1 && g[g[i][0]].size() == 1) {
			if(power[i] >= power[g[i][0]]) {
				used[i] = 1; used[g[i][0]] = 0;
				sum += power[i];
			} else {
				used[i] = 0; used[g[i][0]] = 1;
				sum += power[g[i][0]];
			}
		}
	}
	REP(i,n) {
		ord[i].first = (ll)g[i].size();
		ord[i].second = i;
	}
	sort(ALL(ord)); reverse(ALL(ord));
	return dfs(0, sum);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin >> n;
		if(n == 0) break;
		cout << solve() << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'll solve()':
a.cc:66:19: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::assign(ll&, int)'
   66 |         ord.assign(n,-1);
      |         ~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
  828 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:828:9: note:   template argument deduction/substitution failed:
a.cc:66:19: note:   deduced conflicting types for parameter '_InputIterator' ('long long int' and 'int')
   66 |         ord.assign(n,-1);
      |         ~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int; value_type = std::pair<long long int, long long int>]'
  808 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:47: note:   no known conversion for argument 2 from 'int' to 'const std::vector<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  808 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
  855 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note:   candidate expects 1 argument, 2 provided