CF1621E.New School

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You have decided to open a new school. You have already found nn teachers and mm groups of students. The ii -th group of students consists of ki2k_i \geq 2 students. You know age of each teacher and each student. The ages of teachers are a1,a2,,ana_1, a_2, \ldots, a_n and the ages of students of the ii -th group are bi,1,bi,2,,bi,kib_{i, 1}, b_{i, 2}, \ldots, b_{i, k_i} .

To start lessons you should assign the teacher to each group of students. Such assignment should satisfy the following requirements:

  • To each group exactly one teacher assigned.
  • To each teacher at most 11 group of students assigned.
  • The average of students' ages in each group doesn't exceed the age of the teacher assigned to this group.

The average of set x1,x2,,xkx_1, x_2, \ldots, x_k of kk integers is x1+x2++xkk\frac{x_1 + x_2 + \ldots + x_k}{k} .

Recently you have heard that one of the students will refuse to study in your school. After this, the size of one group will decrease by 11 while all other groups will remain unchanged.

You don't know who will refuse to study. For each student determine if you can start lessons in case of his refusal.

Note, that it is not guaranteed that it is possible to start lessons before any refusal.

输入格式

The first line contains a single integer tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases.

The first line of each test case contains two integers nn and mm ( 1mn1051 \leq m \leq n \leq 10^5 ) — the number of teachers and the number of groups of students.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1051 \leq a_i \leq 10^5 ) — the ages of teachers.

The next 2m2m lines contains descriptions of groups.

The first line of description of group contains a single integer kik_i ( 2ki1052 \leq k_i \leq 10^5 ) — the number of students in this group.

The second line of description of group contains kik_i integers bi,1,bi,2,,bi,kib_{i, 1}, b_{i, 2}, \ldots, b_{i, k_i} ( 1bi,j1051 \leq b_{i, j} \leq 10^5 ) — the ages of students of this group.

It is guaranteed that the total sum of nn over all test cases doesn't exceed 10510^5 and that the total sum of k1+k2++kmk_1 + k_2 + \ldots + k_m over all test cases doesn't exceed 21052 \cdot 10^5

输出格式

For each test case output string of symbols 00 and 11 of length k1+k2++kmk_1 + k_2 + \ldots + k_m . The ii -th symbol of this string should be equals 11 if it is possible to start lessons in case of the ii -th student refuse and it should be equals 00 otherwise.

Students are numbered by integers from 11 to k1+k2++kmk_1 + k_2 + \ldots + k_m in the order they appear in the input. Thus, students of the 11 -st group are numbered by integers 11 , 22 , \ldots , k1k_1 , students of the 22 -nd group are numbered by integers k1+1k_1 + 1 , k1+2k_1 + 2 , \ldots , k1+k2k_1 + k_2 and so on.

输入输出样例

  • 输入#1

    2
    1 1
    30
    3
    25 16 37
    4 2
    9 12 12 6
    2
    4 5
    3
    111 11 11

    输出#1

    101
    00100

说明/提示

In the first test case there is one group of students with average age 25+16+373=26\frac{25+16+37}{3}=26 and one teacher with age 3030 . There exists only one assignment that allows to start lessons.

If the student with age 1616 will refuse to study, the average age of students in this group will become 25+372=31\frac{25+37}{2}=31 so there won't be any assignment that allows to start lessons.

In the second test case it is impossible to start lessons initially. However, if the 33 -rd student with age 111111 will refuse to study, the average ages of groups will become 4+52=4.5\frac{4 + 5}{2}=4.5 and 11+112=11\frac{11+11}{2} = 11 correspondingly. Then it is possible to assing the first group to the first teacher and the second group to the third teacher.

首页