1080 Graduate Admission (30 分)
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.
Each applicant will have to provide two grades: the national entrance exam grade G**E, and the interview grade G**I. The final grade of an applicant is (G**E+G**I)/2. The admission rules are:
The applicants are ranked according to their final grades, and will be admitted one by one from the top of the rank list.
If there is a tied final grade, the applicants will be ranked according to their national entrance exam grade G**E. If still tied, their ranks must be the same.
Each applicant may have K choices and the admission will be done according to his/her choices: if according to the rank list, it is one’s turn to be admitted; and if the quota of one’s most preferred shcool is not exceeded, then one will be admitted to this school, or one’s other choices will be considered one by one in order. If one gets rejected by all of preferred schools, then this unfortunate applicant will be rejected.
If there is a tied rank, and if the corresponding applicants are applying to the same school, then that school must admit all the applicants with the same rank, even if its quota will be exceeded.
Input Specification:
Each input file contains one test case.
Each case starts with a line containing three positive integers: N (≤40,000), the total number of applicants; M (≤100), the total number of graduate schools; and K (≤5), the number of choices an applicant may have.
In the next line, separated by a space, there are M positive integers. The i-th integer is the quota of the i-th graduate school respectively.
Then N lines follow, each contains 2+K integers separated by a space. The first 2 integers are the applicant’s G**E and G**I, respectively. The next Kintegers represent the preferred schools. For the sake of simplicity, we assume that the schools are numbered from 0 to M−1, and the applicants are numbered from 0 to N−1.
Output Specification:
For each test case you should output the admission results for all the graduate schools. The results of each school must occupy a line, which contains the applicants’ numbers that school admits. The numbers must be in increasing order and be separated by a space. There must be no extra space at the end of each line. If no applicant is admitted by a school, you must output an empty line correspondingly.
Sample Input:
1 | 11 6 3 |
Sample Output:
1 | 0 10 |
作者: CHEN, Yue
单位: 浙江大学
时间限制: 250 ms
内存限制: 64 MB
代码长度限制: 16 KB
题目大意
给出n个学生的成绩,以及志愿,要求各个学校录取的学生,规则为:
1.每个学生有Gi,Ge两门成绩,按照总分排序,总分相同按照Ge排序,如果仍相同,那么排名相同
2.按照排名,判断各学生志愿。志愿按照输入顺序,如果某志愿学校有空余名额即录取该学生。
3.如果排名相同的两人报了同一所学校,即便超出名额,也要同时录取两人。
最后输出各学校录取的学生id,按照增序排序。
分析
按照题意模拟即可。其中如果某校仍有名额,或上次录取的学生与当前学生排名相同,即录取当前学生。
代码
1 |
|
五、其他
注意第31行,取消cin/cout的同步,否则测试点4超时。或者将程序中cin/cout改成scanf/printf。