Problem:


Score : 500 points

Problem Statement

We have N locked treasure boxes, numbered 1 to N.

A shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.

Find the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.

Constraints

All values in input are integers.

1 \leq N \leq 12

1 \leq M \leq 10^3

1 \leq a_i \leq 10^5

1 \leq b_i \leq N

1 \leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \leq N

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
c_{11} c_{12} ... c_{1{b_1}}
:
a_M b_M
c_{M1} c_{M2} ... c_{M{b_M}}

Output

Print the minimum cost required to unlock all the treasure boxes.
If it is impossible to unlock all of them, print -1.

Sample Input 1

2 3
10 1
1
15 1
2
30 2
1 2

Sample Output 1

25

We can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.

Sample Input 2

12 1
100000 1
2

Sample Output 2

-1

We cannot unlock all the boxes.

Sample Input 3

4 6
67786 3
1 3 4
3497 1
2
44908 3
2 3 4
2156 3
2 3 4
26230 1
2
86918 1
3

Sample Output 3

69942



Sample input:
2 3
10 1
1
15 1
2
30 2
1 2


Sample output:
25

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
INF = 100100100100100100

def main():
    N, M = map(int, input().split())
    dp = [INF] * (2**N)
    dp[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for i in c:
            key += 2 ** (i-1)
        for j in range(2**N):
            dp[j|key] = min(dp[j|key], dp[j]+a)
    if dp[2**N-1] == INF:
        print(-1)
    else:
        print(dp[2**N-1])


if __name__ == '__main__': main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input=sys.stdin.readline
    n,m=map(int,input().split())
    e=[(int(input().split()[0]),[2**(n-i)for i in map(int,input().split())])for _ in range(m)]
    I=9**9
    dp=[I]*2**n
    dp[0]=0
    for i,dpi in enumerate(dp):
        if dpi==I:continue
        for a,c in e:
            b=i
            for j in c:b|=j
            cost=dpi+a
            if dp[b]>cost:dp[b]=cost
    print(-(dp[-1]==I)or dp[-1])
main()

Submission status: Accepted

Solution code:
n, m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().split(' ')
    a = int(a)
    b = int(b)
    M = 0
    for j in input().split(' '):
        M += 2**(int(j)-1)

    for j in range(2**n):
        # dp[j|M] = min(dp[j]+a, dp[j|M])
        dp[j|M] = dp[j] + a if dp[j] + a < dp[j|M] else dp[j|M]

    # for j in range(2**n):
    #     if dp[j|M] > dp[j] + a:
    #         dp[j|M] = dp[j] + a

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Submission status: Accepted

Solution code:
n, m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().split(' ')
    a = int(a)
    b = int(b)
    M = 0
    for j in input().split(' '):
        M += 2**(int(j)-1)

    # for j in range(2**n):
    #     dp[j|M] = min(dp[j]+a, dp[j|M])

    for j in range(2**n):
        if dp[j|M] > dp[j] + a:
            dp[j|M] = dp[j] + a

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Submission status: Accepted

Solution code:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

Submission status: Accepted

Solution code:
import sys

def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])

def main():
    N,M = LI()
    keys = []
    for _ in range(M):
        a,b = LI()
        C = LI_()
        key_bit = 0
        for c in C:
            key_bit += (1 << c)
        keys.append([a,key_bit])

    dp = [10**10] * (1 << N)
    dp[0] = 0
    for i in range(0,M):
        for key_bit in range(1 << N):
            dp[key_bit|keys[i][1]] = min(dp[key_bit|keys[i][1]],dp[key_bit]+keys[i][0])
    if(dp[(1<<N)-1] == 10**10):
        return(-1)
    return(dp[(1<<N)-1])


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
import sys

def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])

def main():
    N,M = LI()
    keys = []
    for _ in range(M):
        a,b = LI()
        C = LI_()
        key_bit = 0
        for c in C:
            key_bit += (1 << c)
        keys.append([a,key_bit])

    dp = [[10**10] * (1 << N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(0,M):
        for key_bit in range(1 << N):
            dp[i+1][key_bit] = min(dp[i][key_bit],dp[i+1][key_bit])
            dp[i+1][key_bit|keys[i][1]] = min(dp[i+1][key_bit|keys[i][1]],dp[i][key_bit]+keys[i][0])
    if(dp[M][(1<<N)-1] == 10**10):
        return(-1)
    return(dp[M][(1<<N)-1])


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
debug = True

debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def matdprint(mat):
    if debug == True:
        for i in range(len(mat)):
            for j in range(len(mat[i])):
                print(mat[i][j], end=', ')
            print()

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()

INF = 10 ** 18
MOD = 10 ** 9 + 7
def conv(s):
    cnt = 0
    for n in s:
        cnt += 2**n
    return cnt

def main():

    N, M = LI()

    a_list = []
    b_list = []
    c_list = []
    for i in range(M):
        a, b = LI()
        a_list.append(a)
        # b_list.append(b)
        c_list.append(LI())

    dp = [[0 for j in range(2**N)]for i in range(M)]

    def conv(c):
        key = 0
        for i in c:
            key += 2**(i-1)
        return key

    def update(i, j, a):
        if dp[i][j] == 0:
            dp[i][j] = a
        else:
            dp[i][j] = min(dp[i][j], a)

    for i in range(M):
        c = c_list[i]
        a = a_list[i]
        key = conv(c)
        dprint('i', i, 'a', a, 'key', key)

        # 無に自分を入れるパターン
        if dp[i - 1][key] != 0:
            dp[i][key] = min(dp[i - 1][key], a)
        else:
            dp[i][key] = a


        for j in range(2**N):
            org_key = j
            or_key = j | key

            # 直前パターンに自分を足す場合
            # if dp[i-1][org_key] == 0:
            #     # 直前orgがなければ足せない
            #     # dprint('org_key', org_key, 'or_key', or_key, 'pass')
            # else:
            if dp[i - 1][org_key] != 0:

                # 直前がある場合、直前orgに足したのを入れる
                update(i, or_key, dp[i-1][org_key] + a)

                # dprint('org_key', org_key, 'or_key', or_key, dp[i][or_key])

            # 直前パターンをすべて引き継がせる
            if dp[i-1][j] != 0:
                update(i, j, dp[i-1][j])

        # matdprint(dp)

    # matdprint(dp)
    ans = dp[M-1][(2**N)-1]
    if ans == 0:
        print(-1)
    else:
        print(ans)

main()

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
dp = [pow(10, 10) for _ in range(pow(2, n))]

dp[0] = 0
for _ in range(m):
    a, b = list(map(int, input().split()))
    cs = list(map(int, input().split()))
    d = 0
    for c in cs:
        d += pow(2, (c-1))
    for i in range(pow(2, n)):
        dp[i|d] = min(dp[i|d], dp[i] + a)

if dp[pow(2,n)-1] == pow(10, 10):
    print(-1)
else:
    print(dp[pow(2,n)-1])

Submission status: Accepted

Solution code:
import sys

INF = sys.maxsize
N, M = map(int, input().split())
costs = []
keys = []
for _ in range(M):
    a, b = map(int, input().split())
    cs = list(map(int, input().split()))
    costs.append(a)
    # 鍵を2進化で表す
    # e.g. N=5, cs={1,2,5} => key = 10011
    key = 0
    for c in cs:
        key |= 1<<(c-1)
    keys.append(key)

dp = [INF]*(2**N)
dp[0] = 0
for m in range(M):
    a = costs[m]
    key = keys[m]
    for i in range(2**N):
        # keyを追加した場合と追加しない場合のコストを比較
        dp[i|key] = min(dp[i|key], dp[i]+a)
ans = dp[-1]
if ans == INF:
    print(-1)
else:
    # dp[-1] = dp[2**N-1] = dp[0b11...11] = 全ての宝箱が開いたときの最小コスト
    print(dp[-1])

Submission status: Accepted

Solution code:
import subprocess
import gzip, base64, os
import stat

gz = b'H4sIACd4j10C/+19C3hTVbb/SdJHeDUB0VseSsEgRaS0UEqLoi0QOJEUKi2IjnhI05RW26STnEDxCbZVYqgyjtfxzp0H/5k7/udxr+Od/4yDjgMFlOIbURkeooyDemJFig+sOpC71t77pPucnFNg9Lvf9/++idKd9TtrP9baa6/9Otn7brd3gdViEdSPVbhaQMoytpzQ5Qzf7E+xAFYqDIK/44SxQhbQmRxfuVCuCftY0mpoZ3w2+JcB/0qtlC61lmvCsYxPDS1cmCnwn3JN6LpR0ISCkJeKh2U9sJKiB1au0oS5GRQvzNbGs7J4fSxeH+NXQ8EqaEJVvgz2r4bhNUwuNZzP+OZz/Pipek+uw+8N1ZRuqC7XhJsY3yZdvOsgXpZw7h8nC5ey/Mz0ks/Kr4ZqPUxraqwtKZ7WVDe1qTEYbZ3aWloytaS4IBIqmE7K5GS8Cxcv0+gxl5V5JLMBfL5zyqU7C0atqH+hadhVR+PXHxrzwPet+Gw2i4dV0hF0NmSMH2S1CMXCekgan82Bf3Ph3+/emvHm4A2bpR/7//zcA83JPRs7/Be9Ub2lbdMN5SennpRuzslbU5jvftPb9eFlXSMfHTrvJ2Nbtq7z3PrkQPo5BgUYYYC/bjXGp1mM8d8JxrgzZWHazzgT/NVM43TuNMFfNMm304R/SZYxnm2C32yC35dhjDea5DvVJJ1SEz3/wQQfZZLODBN9rjZJp8UknU9M+C8z4V9iku/3Teol08R+akzyfdqEf5hJeVaZ8C834T9lYv/jTdJ5zKTenzLBnzZJ/y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ouheID+HKAbvTJ89Vv+b2WfnLdOKUH2eWqo+fy1Vn7+Wqv8hLVWfh5aqz0tLy89TS8vPX0vLz7Xw/rAckaP19QV+QZKunbdU8nqqayRJ6L/0V5KbJT9e7hsRDCBJqgtJq5tCtb4mqQ5adkTyRVsFf6i5pSkgB+oKSspKpxszSf1b3xIoPrxOoNvnddHm5nUQhaOk/h1zxipJC5ZWVLrBb8zHq4tJydl3JvWSBQuq3TVSTcVcrxs5NEnUaQFyaaUgzb9hcUWlZ56Ae+0qpr9Ptbycv4py4Ptndbz0gkx/JEokF1I5nOdVrPoSGN5SnFZMw3uUNVwFZed0IzS5dTQ9ee5uUwMVDXBVs7YMRUUC047x/ajatOkVpAxjN4qS6021UNrVpLrHA15Iq5cm7WpXfS3335uano3JNcrpVWp65XFabvjKjYR3t0qpC6L/sQuhtSmTO2ENBEi/MFpXogFvDF8ikd+GSdFIoC79omhdCcKBQFoBBrrOWRud3mOrS2CAK8v1jd70VnIj8067r9fQTRhdOm7QkgyuFNZzGdxSrTcMEE/1iGl3dKfbG7naOR3mLh3Xp18XCUkN0NOC8uhdwoZtDr0dG0J9i5ej6/0Wu4NYby3ay7310qVfi60XsTYS4SwidTN8WmWc03XR5eXcXcfpl1wbepG0G6/TE9HeCm6UCrYjsxSkFhAdxvnSrYF1zPOZ3m+vc73kSmitxv0G7vgb3P2ucweBUL3exFA8UndaqUj//o/dv67Lk/y8NM2szvn6c4OuehbfVRN9rTFzASZXyxvVMXc3vU4V5L1Bo0vl003pW7g83aCzNJCO9Xppzk9zYzk8Y1eHk8KVYFNoChh0ONzd8gajHno7vEEhwNYqJbC7W8GLwWTBwLxb1vXXfFFx+g3s+rFIY1Cgvu5/AFj8a6spjQAA'
bin = gzip.decompress(base64.b64decode(gz))
p = os.path.dirname(__file__)
pymain = os.path.join(p, "a.out")
with open(pymain, "wb") as f:
    f.write(bin)
os.chmod(pymain, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if p == "":
    pymain = "./" + pymain
subprocess.call(pymain)


# compiled by pythran
'''
#pythran export main2()
import numpy as np

i8 = np.int64
i4 = np.int32


def solve(a, c, mark):
    for i in range(c.shape[0]):
        for j in range(mark.shape[0] - 1):
            if mark[j | c[i]] > mark[j] + a[i]:
                mark[j | c[i]] = mark[j] + a[i]

    if mark[-1] < 10 ** 10:
        return mark[-1]
    else:
        return -1


def main2():
    stdin = open('/dev/stdin')
    N, M = map(int, stdin.readline().split())
    a = np.zeros(M, i8)
    c = np.zeros(M, i8)
    for i in range(M):
        a[i], b = map(int, stdin.readline().split())
        for d in stdin.readline().split():
            c[i] += 1 << (int(d) - 1)
    mark = np.empty(2 ** N, i8)
    mark[0] = 0
    for i in range(1, 2 ** N):
        mark[i] = 10 ** 10
    ans = solve(a, c, mark)
    print(ans)
'''

Submission status: Accepted

Solution code:
def solve():
  N, M = map(int, input().split())
  DP = [float('inf')] * (2 ** N)
  DP[0] = 0

  for i in range(M):
    A, B = map(int, input().split())
    keys = sum(1 << (int(i) - 1) for i in input().split())
    for j in range(2 ** N): DP[j | keys] = min(DP[j | keys], DP[j] + A)
  return DP[-1] if DP[-1] != float('inf') else -1

print(solve())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def solve(N,M,A,B,C):
    dp = [float('Inf') for _ in range(2**N)]
    dp[0] = 0

    def f(C):
        return(sum(map(lambda x:2**(x-1),C)))

    for i in range(1,M+1):
        c = f(C[i-1])
        for d in range(0,2**N):
            dp[d | c] = min(dp[d | c], dp[d] + A[i-1])

    print(dp[-1] if dp[-1] != float("inf") else -1)





def main():
    # Failed to predict input format
    N,M = map(int,input().split())
    A = []
    B = []
    C = []
    CA = set()

    for _ in range(M): 
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
        c = list(map(int,input().split()))
        C.append(set(c))

    solve(N,M,A,B,C)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
k = []
g = []
INF = float("inf")
for i in range(m):
    k.append(list(map(int, input().split()))[0])
    # g: indexの鍵で開けられる箱をbit列として表現
    g.append(sum(map(lambda x: 2**(int(x)-1), input().split())))

dp = [INF] * (2**n)
dp[0] = 0

for i in range(m):
    for j in range(2**n):
        dp[g[i]|j] = min(dp[g[i]|j], dp[j] + k[i])
#print(dp)
print(-1 if dp[-1] == INF else dp[-1])

Submission status: Accepted

Solution code:
N,M=map(int,input().split());D=[0]+[9**9]*(1<<N)
for i in range(M):
 a=int(input().split()[0]);s=sum(1<<~-int(c)for c in input().split())
 for j in range(1<<N):D[s|j]=min(D[s|j],D[j]+a)
print(D[-2]%(9**9)or-1)

Submission status: Accepted

Solution code:
from collections import deque as dq
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ab = []
c = []
inf = 2 << 31
for i in range(M):
  ab.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
dp = [[inf] * M for _ in range(2 ** 12)]
cc = []
for i in range(M):
  temp = 0
  for k in range(ab[i][1]):
    t = 2 ** (c[i][k] - 1)
    temp = temp | t
  cc.append(temp)
def less(a, b):
  if a > b:
    return b
  else:
    return a
#print(ab, c)
Q = dq([])
Q.append((0, 0))
vis = [[0] * M for _ in range(2 ** 12)]
while len(Q):
  q = Q.popleft()
  i, j = q[0], q[1]
  if j >= M:
    continue
  if vis[i][j] == 1:
    continue
  vis[i][j] = 1
  temp = i ^ 0
  temp2 = cc[j]
  if j > 0:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(dp[temp][j - 1] + ab[j][0], dp[temp | temp2][j])
    dp[temp][j] = less(dp[temp][j], dp[temp][j - 1])
    dp[temp2][j] = less(ab[j][0], dp[temp2][j])
    Q.append((temp | temp2, j + 1))
    Q.append((temp, j + 1))
    Q.append((temp2, j + 1))
  else:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(ab[j][0], dp[temp | temp2][j])
    Q.append((temp | temp2, j + 1))
if dp[2 ** N - 1][-1] == inf:
  print(-1)
else:
  print(dp[2 ** N - 1][-1])

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

dp = [float("inf")] * (2 ** N)

dp[0] = 0

for i in range(M):

    a, b = map(int, input().split())
    c = list(map(int, input().split()))

    key = 0

    for j in c:
        key += 2 ** (j-1)

    for j in range(2**N):
        if dp[j | key] > dp[j] + a:
            dp[j | key] = dp[j] + a

if dp[2 ** N - 1] == float("inf"):
    print(-1)
else:
    print(dp[2 ** N - 1])

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = []
for _ in range(M):
    a, b = map(int, input().split())
    c_list = list(map(int, input().split()))
    AC.append([a, c_list])

AC = sorted(AC, key=lambda x:x[0])
dp = [10**9]*2**N
dp[0] = 0
for m in range(M):
    a, c_list = AC[m]
    c_bi = 0
    for c in c_list:
        c_bi += 2**(c-1)
    for i in range(2**N):
        dp[i|c_bi] = min(dp[i|c_bi], dp[i]+a) # コストaで行ける場所

ans = dp[-1]
if ans > 10**8:
    print(-1)
else:
    print(dp[-1])