Language: C++

#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int inf=1001001001;



int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        int ans=0;
        rep(j,b){
            int c;
            cin>>c; c--;
            ans|=(1<<c);
        }
        //cout<<ans<<endl;
        v.emplace_back(a,ans);
    }
    
    vector<int> dp(1<<n,inf);
    dp[0]=0;
    //配るDP
    rep(s,1<<n){
        rep(j,m){
            int t=s|v[j].second;
            dp[t]=min(dp[t],dp[s]+v[j].first);
        }
    }
    
    if (dp[(1<<n)-1]==inf) {
        cout<<-1<<endl;
      return 0;
    }
    cout<<dp[(1<<n)-1];
    
    return 0;
    
    vector<vector<int>> dp(m+1,vector<int>(1<<n,inf));
    dp[0][0]=0;
    rep(i,m){
        rep(s,1<<n){
            if (dp[i][s]!=inf){
                int t=s|v[i].second;
                int cost=v[i].first;
                dp[i+1][t]=min(dp[i+1][t],dp[i][s]+cost);
                dp[i+1][s]=min(dp[i+1][s],dp[i][s]);
            }
        }
    }
    
    
    cout<<dp[m][(1<<n)-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:81:25: error: conflicting declaration 'std::vector<std::vector<int> > dp'
   81 |     vector<vector<int>> dp(m+1,vector<int>(1<<n,inf));
      |                         ^~
a.cc:63:17: note: previous declaration as 'std::vector<int> dp'
   63 |     vector<int> dp(1<<n,inf);
      |                 ^~
a.cc:82:10: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   82 |     dp[0][0]=0;
      |          ^
a.cc:85:22: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   85 |             if (dp[i][s]!=inf){
      |                      ^
a.cc:88:24: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   88 |                 dp[i+1][t]=min(dp[i+1][t],dp[i][s]+cost);
      |                        ^
a.cc:88:39: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   88 |                 dp[i+1][t]=min(dp[i+1][t],dp[i][s]+cost);
      |                                       ^
a.cc:88:48: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   88 |                 dp[i+1][t]=min(dp[i+1][t],dp[i][s]+cost);
      |                                                ^
a.cc:89:24: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   89 |                 dp[i+1][s]=min(dp[i+1][s],dp[i][s]);
      |                        ^
a.cc:89:39: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   89 |                 dp[i+1][s]=min(dp[i+1][s],dp[i][s]);
      |                                       ^
a.cc:89:48: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   89 |                 dp[i+1][s]=min(dp[i+1][s],dp[i][s]);
      |                                                ^
a.cc:95:16: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   95 |     cout<<dp[m][(1<<n)-1]<<endl;
      |                ^