CF1574D.The Strongest Build

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Ivan is playing yet another roguelike computer game. He controls a single hero in the game. The hero has nn equipment slots. There is a list of cic_i items for the ii-th slot, the jj-th of them increases the hero strength by ai,ja_{i,j}. The items for each slot are pairwise distinct and are listed in the increasing order of their strength increase. So, ai,1<ai,2<⋯<ai,cia_{i,1} \lt a_{i,2} \lt \dots \lt a_{i,c_i}.

For each slot Ivan chooses exactly one item. Let the chosen item for the ii-th slot be the bib_i-th item in the corresponding list. The sequence of choices [b1,b2,…,bn][b_1, b_2, \dots, b_n] is called a build.

The strength of a build is the sum of the strength increases of the items in it. Some builds are banned from the game. There is a list of mm pairwise distinct banned builds. It's guaranteed that there's at least one build that's not banned.

What is the build with the maximum strength that is not banned from the game? If there are multiple builds with maximum strength, print any of them.

伊万正在玩另一款类Roguelike电脑游戏。他在游戏中控制一名英雄。该英雄有 nn 个装备栏位。第 ii 个栏位有 cic_i 件可选物品,其中第 jj 件物品使英雄力量提升 ai,ja_{i,j}。每个栏位的物品互不相同,且按其力量提升值升序排列,即满足 ai,1<ai,2<⋯<ai,cia_{i,1} \lt a_{i,2} \lt \dots \lt a_{i,c_i}。

对于每个栏位,伊万必须恰好选择一件物品。设第 ii 个栏位所选物品为其对应列表中的第 bib_i 件,则选择序列 [b1,b2,…,bn][b_1, b_2, \dots, b_n] 称为一个“构筑”(build)。

一个构筑的力量值等于其所选所有物品的力量提升值之和。游戏中存在若干被禁止的构筑。给定一个包含 mm 个两两不同的被禁构筑的列表。保证至少存在一个未被禁止的构筑。

请找出所有未被禁止的构筑中力量值最大的那个。若存在多个力量值最大的未被禁止构筑,输出任意一个即可。

输入格式

The first line contains a single integer nn (1≤n≤101 \le n \le 10) — the number of equipment slots.

The ii-th of the next nn lines contains the description of the items for the ii-th slot. First, one integer cic_i (1≤ci≤2⋅1051 \le c_i \le 2 \cdot 10^5) — the number of items for the ii-th slot. Then cic_i integers ai,1,ai,2,…,ai,cia_{i,1}, a_{i,2}, \dots, a_{i,c_i} (1≤ai,1<ai,2<⋯<ai,ci≤1081 \le a_{i,1} \lt a_{i,2} \lt \dots \lt a_{i,c_i} \le 10^8).

The sum of cic_i doesn't exceed 2⋅1052 \cdot 10^5.

The next line contains a single integer mm (0≤m≤1050 \le m \le 10^5) — the number of banned builds.

Each of the next mm lines contains a description of a banned build — a sequence of nn integers b1,b2,…,bnb_1, b_2, \dots, b_n (1≤bi≤ci1 \le b_i \le c_i).

The builds are pairwise distinct, and there's at least one build that's not banned.

第一行包含一个整数 nn(1≤n≤101 \le n \le 10)—— 表示装备槽的数量。

接下来的 nn 行中,第 ii 行描述第 ii 个装备槽可选的物品。首先是一个整数 cic_i(1≤ci≤2⋅1051 \le c_i \le 2 \cdot 10^5)—— 表示第 ii 个装备槽的物品数量;随后是 cic_i 个整数 ai,1,ai,2,…,ai,cia_{i,1}, a_{i,2}, \dots, a_{i,c_i}(1≤ai,1<ai,2<⋯<ai,ci≤1081 \le a_{i,1} \lt a_{i,2} \lt \dots \lt a_{i,c_i} \le 10^8)。

所有 cic_i 的总和不超过 2⋅1052 \cdot 10^5。

下一行包含一个整数 mm(0≤m≤1050 \le m \le 10^5)—— 表示被禁止的装备组合数量。

接下来的 mm 行每行描述一个被禁止的装备组合:即一个由 nn 个整数组成的序列 b1,b2,…,bnb_1, b_2, \dots, b_n(1≤bi≤ci1 \le b_i \le c_i)。

所有被禁止的装备组合两两不同,且至少存在一个未被禁止的装备组合。

输出格式

Print the build with the maximum strength that is not banned from the game. If there are multiple builds with maximum strength, print any of them.

输出游戏中未被禁止的、强度最大的构筑。如果存在多个强度最大的构筑,则输出其中任意一个。

输入输出样例

  • 输入#1

    3
    3 1 2 3
    2 1 5
    3 2 4 6
    2
    3 2 3
    3 2 2

    输出#1

    2 2 3
  • 输入#2

    3
    3 1 2 3
    2 1 5
    3 2 4 6
    2
    3 2 3
    2 2 3

    输出#2

    1 2 3
  • 输入#3

    3
    3 1 2 3
    2 1 5
    3 2 4 6
    2
    3 2 3
    2 2 3

    输出#3

    3 2 2
  • 输入#4

    4
    1 10
    1 4
    1 7
    1 3
    0

    输出#4

    1 1 1 1

输入解题思路,AI测评打分。不知道怎么写?

首页