306926: CF1271F. Divide The Students

Memory Limit:512 MB Time Limit:8 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Divide The Students

题意翻译

#### 题目描述 最近有许多学生报名了 Berland 州大学。所有的学生被分到了不同的组,但后来人们发现有些组实在是太大了,以至于不能在同一个教室上课,因此这些组要被分成两个小组。你的任务是帮助学校把计算机科学学院一年级的学生分小组。 计算机科学学院一共有 $t$ 组学生。每个学生有三门功课:数学、编程和体育。每门课的教室不一样——数学课在礼堂上,编程课在机房上,体育课在体育馆上。 每一组都要被分成两个小组,使得每个小组的每个教室都能够容纳这个小组来上这一门课的所有学生。对于第 $i$ 个组的第一个小组,数学课的上课地点是一个可以容纳 $a_{i,1}$ 个学生的礼堂,编程课的上课地点是一个可以容纳 $b_{i,1}$ 个学生的机房,体育课的上课地点是一个可以容纳 $c_{i,1}$ 个学生的体育馆。类似地,第二个小组的礼堂、机房和体育馆分别可以容纳 $a_{i,2},b_{i,2},c_{i,2}$ 个学生。 和通常一样,有些学生会翘课。每个学生都认为,这三门功课中的 $0\sim 3$ 门是没用的,他会翘掉这些他认为没用的课,只上其他的课。这个数据会按下面的格式给出。第 $i$ 个组有: 1. $d_{i,1}$ 名学生上所有的课 2. $d_{i,2}$ 名学生上数学和编程课 3. $d_{i,3}$ 名学生上数学和体育课 4. $d_{i,4}$ 名学生只上数学课 5. $d_{i,5}$ 名学生上编程和体育课 6. $d_{i,6}$ 名学生只上编程课 7. $d_{i,7}$ 名学生只上体育课 事实上还有一些什么课都不上的学生,他们不会占用任何教室空间,所以在这个问题中我们不需要知道他们有多少人,处理他们是教务处的事(大雾)。 你的任务是把每一个组分成两个小组,使得每个小组的礼堂、机房和体育馆都有足够的空间容纳这个小组要上这门课的学生(如果可能的话)。第 $i$ 个组的每一个学生都必须恰属于某一个小组(第一小组或第二小组),禁止在组之间调剂学生(不服从调剂)。 #### 输入格式 输入的第一行有一个整数 $t\ (1\le t\le 300)$,表示组的数量。 接下来描述这 $t$ 个组。第 $i$ 个组的描述有三行: - 描述的第一行有三个整数 $a_{i,1},b_{i,1},c_{i,1}\ (1 \le a_{i, 1}, b_{i, 1}, c_{i, 1} \le 3000)$,分别表示这个组的第一小组的礼堂、机房和体育馆的容量 - 描述的第二行有三个整数 $a_{i,2},b_{i,2},c_{i,2}\ (1 \le a_{i, 2}, b_{i, 2}, c_{i, 2} \le 3000)$,分别表示这个组的第二小组的礼堂、机房和体育馆的容量 - 描述的第三行有七个整数 $d_{i,1},d_{i,2},\cdots,d_{i,7}\ (0 \le d_{i, j} \le 3000)$,分别表示第 $i$ 个组中前面提到的七类学生的人数。并不保证 $d_{i,1}+d_{i,2}+\cdots+d_{i,7}$ 是正数,因为一个组可以只包含全部翘课的学生(这样的组好危险)。 数据保证所有 $t$ 个组的学生总数不超过 $3000$。 #### 输出格式 对于每个组,输出一行表示划分方案,格式如下。 - 如果不可能把这个组分成符合题意的两个小组,那么输出一行一个整数 $-1$ - 否则输出一行七个以空格分隔的整数 $f_{i,1},f_{i,2},\cdots,f_{i,7} \ (0\le f_{i,j} \le d_{i,j})$,分别表示**第一小组**的第一类到第七类的学生人数(其他的学生会被分到第二小组)。如果有多组解,可以输出任意一组。 #### 样例输入 ```plain 3 9 4 13 1 10 3 1 2 3 4 5 6 7 9 4 13 1 10 3 2 1 3 4 5 6 7 1 2 3 4 5 6 0 0 0 0 0 0 0 ``` #### 样例输出 ```plain 1 1 3 4 2 0 7 -1 0 0 0 0 0 0 0 ```

题目描述

Recently a lot of students were enrolled in Berland State University. All students were divided into groups according to their education program. Some groups turned out to be too large to attend lessons in the same auditorium, so these groups should be divided into two subgroups. Your task is to help divide the first-year students of the computer science faculty. There are $ t $ new groups belonging to this faculty. Students have to attend classes on three different subjects — maths, programming and P. E. All classes are held in different places according to the subject — maths classes are held in auditoriums, programming classes are held in computer labs, and P. E. classes are held in gyms. Each group should be divided into two subgroups so that there is enough space in every auditorium, lab or gym for all students of the subgroup. For the first subgroup of the $ i $ -th group, maths classes are held in an auditorium with capacity of $ a_{i, 1} $ students; programming classes are held in a lab that accomodates up to $ b_{i, 1} $ students; and P. E. classes are held in a gym having enough place for $ c_{i, 1} $ students. Analogically, the auditorium, lab and gym for the second subgroup can accept no more than $ a_{i, 2} $ , $ b_{i, 2} $ and $ c_{i, 2} $ students, respectively. As usual, some students skip some classes. Each student considers some number of subjects (from $ 0 $ to $ 3 $ ) to be useless — that means, he skips all classes on these subjects (and attends all other classes). This data is given to you as follows — the $ i $ -th group consists of: 1. $ d_{i, 1} $ students which attend all classes; 2. $ d_{i, 2} $ students which attend all classes, except for P. E.; 3. $ d_{i, 3} $ students which attend all classes, except for programming; 4. $ d_{i, 4} $ students which attend only maths classes; 5. $ d_{i, 5} $ students which attend all classes, except for maths; 6. $ d_{i, 6} $ students which attend only programming classes; 7. $ d_{i, 7} $ students which attend only P. E. There is one more type of students — those who don't attend any classes at all (but they, obviously, don't need any place in auditoriums, labs or gyms, so the number of those students is insignificant in this problem). Your task is to divide each group into two subgroups so that every auditorium (or lab, or gym) assigned to each subgroup has enough place for all students from this subgroup attending the corresponding classes (if it is possible). Each student of the $ i $ -th group should belong to exactly one subgroup of the $ i $ -th group; it is forbidden to move students between groups.

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 300 $ ) — the number of groups. Then the descriptions of groups follow. The description of the $ i $ -th group consists of three lines: - the first line contains three integers $ a_{i, 1} $ , $ b_{i, 1} $ and $ c_{i, 1} $ ( $ 1 \le a_{i, 1}, b_{i, 1}, c_{i, 1} \le 3000 $ ) — the capacity of the auditorium, lab and gym assigned to the first subgroup of the $ i $ -th group, respectively; - the second line contains three integers $ a_{i, 2} $ , $ b_{i, 2} $ and $ c_{i, 2} $ ( $ 1 \le a_{i, 2}, b_{i, 2}, c_{i, 2} \le 3000 $ ) — the capacity of the auditorium, lab and gym assigned to the second subgroup of the $ i $ -th group, respectively; - the third line contains integers $ d_{i, 1} $ , $ d_{i, 2} $ , ..., $ d_{i, 7} $ ( $ 0 \le d_{i, j} \le 3000 $ ) — the number of students belonging to each of the seven aforementioned types in the $ i $ -th group. It is not guaranteed that the sum of these values is positive — a group can consist entirely of students that don't attend classes at all. It is guaranteed that the total number of students in all groups is not greater than $ 3000 $ .

输出格式


For each group, print the result of its division as follows: - if it is impossible to divide the group, print one integer $ -1 $ ; - otherwise print seven integers $ f_{i, 1} $ , $ f_{i, 2} $ , ..., $ f_{i, 7} $ ( $ 0 \le f_{i, j} \le d_{i, j} $ ) — the number of students the first, second, ..., seventh type in the first subgroup of the $ i $ -th group (all other students will be assigned to the second subgroup). If there are multiple answers, print any of them.

输入输出样例

输入样例 #1

3
9 4 13
1 10 3
1 2 3 4 5 6 7
9 4 13
1 10 3
2 1 3 4 5 6 7
1 2 3
4 5 6
0 0 0 0 0 0 0

输出样例 #1

1 1 3 4 2 0 7
-1
0 0 0 0 0 0 0

Input

题意翻译

#### 题目描述 最近有许多学生报名了 Berland 州大学。所有的学生被分到了不同的组,但后来人们发现有些组实在是太大了,以至于不能在同一个教室上课,因此这些组要被分成两个小组。你的任务是帮助学校把计算机科学学院一年级的学生分小组。 计算机科学学院一共有 $t$ 组学生。每个学生有三门功课:数学、编程和体育。每门课的教室不一样——数学课在礼堂上,编程课在机房上,体育课在体育馆上。 每一组都要被分成两个小组,使得每个小组的每个教室都能够容纳这个小组来上这一门课的所有学生。对于第 $i$ 个组的第一个小组,数学课的上课地点是一个可以容纳 $a_{i,1}$ 个学生的礼堂,编程课的上课地点是一个可以容纳 $b_{i,1}$ 个学生的机房,体育课的上课地点是一个可以容纳 $c_{i,1}$ 个学生的体育馆。类似地,第二个小组的礼堂、机房和体育馆分别可以容纳 $a_{i,2},b_{i,2},c_{i,2}$ 个学生。 和通常一样,有些学生会翘课。每个学生都认为,这三门功课中的 $0\sim 3$ 门是没用的,他会翘掉这些他认为没用的课,只上其他的课。这个数据会按下面的格式给出。第 $i$ 个组有: 1. $d_{i,1}$ 名学生上所有的课 2. $d_{i,2}$ 名学生上数学和编程课 3. $d_{i,3}$ 名学生上数学和体育课 4. $d_{i,4}$ 名学生只上数学课 5. $d_{i,5}$ 名学生上编程和体育课 6. $d_{i,6}$ 名学生只上编程课 7. $d_{i,7}$ 名学生只上体育课 事实上还有一些什么课都不上的学生,他们不会占用任何教室空间,所以在这个问题中我们不需要知道他们有多少人,处理他们是教务处的事(大雾)。 你的任务是把每一个组分成两个小组,使得每个小组的礼堂、机房和体育馆都有足够的空间容纳这个小组要上这门课的学生(如果可能的话)。第 $i$ 个组的每一个学生都必须恰属于某一个小组(第一小组或第二小组),禁止在组之间调剂学生(不服从调剂)。 #### 输入格式 输入的第一行有一个整数 $t\ (1\le t\le 300)$,表示组的数量。 接下来描述这 $t$ 个组。第 $i$ 个组的描述有三行: - 描述的第一行有三个整数 $a_{i,1},b_{i,1},c_{i,1}\ (1 \le a_{i, 1}, b_{i, 1}, c_{i, 1} \le 3000)$,分别表示这个组的第一小组的礼堂、机房和体育馆的容量 - 描述的第二行有三个整数 $a_{i,2},b_{i,2},c_{i,2}\ (1 \le a_{i, 2}, b_{i, 2}, c_{i, 2} \le 3000)$,分别表示这个组的第二小组的礼堂、机房和体育馆的容量 - 描述的第三行有七个整数 $d_{i,1},d_{i,2},\cdots,d_{i,7}\ (0 \le d_{i, j} \le 3000)$,分别表示第 $i$ 个组中前面提到的七类学生的人数。并不保证 $d_{i,1}+d_{i,2}+\cdots+d_{i,7}$ 是正数,因为一个组可以只包含全部翘课的学生(这样的组好危险)。 数据保证所有 $t$ 个组的学生总数不超过 $3000$。 #### 输出格式 对于每个组,输出一行表示划分方案,格式如下。 - 如果不可能把这个组分成符合题意的两个小组,那么输出一行一个整数 $-1$ - 否则输出一行七个以空格分隔的整数 $f_{i,1},f_{i,2},\cdots,f_{i,7} \ (0\le f_{i,j} \le d_{i,j})$,分别表示**第一小组**的第一类到第七类的学生人数(其他的学生会被分到第二小组)。如果有多组解,可以输出任意一组。 #### 样例输入 ```plain 3 9 4 13 1 10 3 1 2 3 4 5 6 7 9 4 13 1 10 3 2 1 3 4 5 6 7 1 2 3 4 5 6 0 0 0 0 0 0 0 ``` #### 样例输出 ```plain 1 1 3 4 2 0 7 -1 0 0 0 0 0 0 0 ```

加入题单

算法标签: