CF1574D.The Strongest Build

普及/提高-

通过率:0%

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} < a_{i,2} < \dots < 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.

输入格式

The first line contains a single integer nn ( 1n101 \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 ( 1ci21051 \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} ( 1ai,1<ai,2<<ai,ci1081 \le a_{i,1} < a_{i,2} < \dots < a_{i,c_i} \le 10^8 ).

The sum of cic_i doesn't exceed 21052 \cdot 10^5 .

The next line contains a single integer mm ( 0m1050 \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 ( 1bici1 \le b_i \le c_i ).

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

输出格式

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
首页