luogu#P4923. [MtOI2018] gcd?人生赢家!

    ID: 3897 远端评测题 150ms 20MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2018洛谷原创O2优化枚举最短路状压 DP

[MtOI2018] gcd?人生赢家!

Background

gcd is a person who loves games.

Problem Description

gcd has recently been playing an interesting game.

We abstract this game into a graph with nn nodes. gcd needs to find a total of mm treasures, which are distributed on the graph.

For each treasure, there is a prerequisite set SS. Only after obtaining all prerequisite treasures can this treasure be obtained.

gcd has a divine artifact. This artifact can teleport, and it can be used kk times. Each time, it can teleport to any node.

In this game, there are also extra achievements. These achievements reward a certain number of teleport uses. An achievement is completed at the instant when the set SS is satisfied.

Now gcd wants to know the fastest way to clear the game. Please find the minimum time needed to clear it.

Input Format

The input has a total of s+m+e+6s+m+e+6 lines.

Line 11 contains 33 positive integers n,m,kn,m,k.

Line 22 contains 11 positive integer ss, the number of achievements.

In the next ss lines, each line starts with 11 non-negative integer numnum, meaning how many treasures are required, followed by numnum integers, which are the IDs of the required treasures.

Line s+3s+3 contains ss positive integers a1,a2,asa_1,a_2,\cdots a_s, meaning the reward counts of the achievements.

Line s+4s+4 contains mm positive integers p1,p2,pmp_1,p_2,\cdots p_m, meaning the positions of the treasures.

Line s+5s+5 contains 11 positive integer ee, the total number of edges.

In the next ee lines, each line contains 33 positive integers x,y,zx,y,z, meaning there is an undirected edge between xx and yy with weight zz.

In the next mm lines, each line starts with 11 non-negative integer numnum, meaning the number of prerequisites for the treasure, followed by numnum integers, which are the IDs of the required treasures.

The last line contains 11 positive integer stst, the starting node.

Output Format

Output 11 line with 11 positive integer: the minimum time.

3 2 0
1
1 1
1
2 3
3
1 2 20
1 3 20
3 2 1
0
0
1

20
3 2 0
1
1 1
1
2 3
3
1 2 1
1 3 20
3 2 20
1 2
0
1
40

Hint

Subtasks

For 20%20\% of the testdata, s=0s=0.

For 100%100\% of the testdata, n200n\leq 200, m12m\leq 12, k4k\leq 4, s8s\leq 8, e20000e\leq 20000. The sum of all reward counts does not exceed 88. It is guaranteed that the positions of any two treasures are different. There may be multiple edges. It is guaranteed that a solution exists.

Source

MtOI2018 迷途の家の水题大赛 T5

Problem setter: b2019dy

78488

Translated by ChatGPT 5