Submission #7778016


Source Code Expand

Copy
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const int INF=1e18;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,M; cin>>N>>M;
    vector<int> a(M),T(M);
    for(int i=0;i<M;i++){
        int k; cin>>a[i]>>k;
        while(k--){
            int c; cin>>c;
            c--;
            T[i]|=1<<c;
        }
    }

    vector<vector<int>> dp(M+1,vector<int>(1<<N,INF));
    dp[0][0]=0;
    for(int i=0;i<M;i++){
        for(int S=0;S<(1<<N);S++){
            chmin(dp[i+1][S],dp[i][S]);
            chmin(dp[i+1][S|T[i]],dp[i][S]+a[i]);
        }
    }
    int ans=dp[N][(1<<N)-1];
    cout<<(ans==INF? -1:ans)<<endl;
    return 0;
}

Submission Info

Submission Time
Task E - Get Everything
User tekihei2317
Language C++14 (GCC 5.4.1)
Score 0
Code Size 895 Byte
Status RE
Exec Time 97 ms
Memory 32384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
RE × 1
AC × 4
WA × 35
RE × 1
Set Name Test Cases
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 01-handmade-07, 02-random-08, 02-random-09, 02-random-10, 02-random-11, 02-random-12, 02-random-13, 02-random-14, 02-random-15, 02-random-16, 02-random-17, 02-random-18, 02-random-19, 02-random-20, 02-random-21, 02-random-22, 02-random-23, 02-random-24, 02-random-25, 02-random-26, 02-random-27, 02-random-28, 02-random-29, 02-random-30, 02-random-31, 02-random-32, 02-random-33, 02-random-34, 02-random-35, 02-random-36, 02-random-37, 02-random-38, 02-random-39
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
00-sample-01 RE 97 ms 384 KB
00-sample-02 AC 1 ms 256 KB
01-handmade-03 WA 1 ms 384 KB
01-handmade-04 AC 27 ms 32384 KB
01-handmade-05 WA 1 ms 512 KB
01-handmade-06 WA 3 ms 2688 KB
01-handmade-07 AC 23 ms 32384 KB
02-random-08 WA 6 ms 5888 KB
02-random-09 WA 1 ms 384 KB
02-random-10 WA 5 ms 4224 KB
02-random-11 WA 3 ms 2560 KB
02-random-12 WA 4 ms 2816 KB
02-random-13 WA 4 ms 3840 KB
02-random-14 WA 3 ms 1664 KB
02-random-15 WA 6 ms 5760 KB
02-random-16 WA 8 ms 7168 KB
02-random-17 WA 5 ms 3712 KB
02-random-18 WA 8 ms 7936 KB
02-random-19 WA 6 ms 5888 KB
02-random-20 WA 2 ms 1664 KB
02-random-21 WA 14 ms 13696 KB
02-random-22 WA 23 ms 25344 KB
02-random-23 WA 3 ms 2432 KB
02-random-24 WA 15 ms 16384 KB
02-random-25 WA 15 ms 15488 KB
02-random-26 WA 7 ms 7808 KB
02-random-27 WA 3 ms 1920 KB
02-random-28 WA 4 ms 3584 KB
02-random-29 WA 12 ms 13824 KB
02-random-30 WA 3 ms 2688 KB
02-random-31 WA 15 ms 16128 KB
02-random-32 WA 5 ms 5760 KB
02-random-33 WA 4 ms 3456 KB
02-random-34 WA 4 ms 3328 KB
02-random-35 WA 16 ms 17536 KB
02-random-36 WA 6 ms 4992 KB
02-random-37 WA 1 ms 512 KB
02-random-38 WA 3 ms 1792 KB
02-random-39 WA 13 ms 15616 KB