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 (. 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 (≤), the total number of applicants; M (≤), the total number of graduate schools; and K (≤), 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 integers separated by a space. The first 2 integers are the applicant's G​E​​ and G​I​​, respectively. The next K integers 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:

11 6 3
2 1 2 2 2 3
100 100 0 1 2
60 60 2 3 5
100 90 0 3 4
90 100 1 2 0
90 90 5 1 3
80 90 1 0 2
80 80 0 1 2
80 80 0 1 2
80 70 1 3 2
70 80 1 2 3
100 100 0 2 4

Sample Output:

0 10
3
5 6 7
2 8 1 4
 #include <iostream>
#include <vector>
#include <algorithm>
//录取规则,排名靠前的人优先选择学校
using namespace std;
int N, M, K;
struct Node
{
int id, Ge, Gt, G, rank, choice[];
}node;
struct Sch
{
int quto;
vector<pair<int,int>>admin;//录取的学生id,rank
}sch;
vector<Sch>school;
vector<Node>applicant;
bool cmp(Node a, Node b)
{
if (a.G != b.G)
return a.G > b.G;
else
return a.Ge > b.Ge;
}
int main()
{
cin >> N >> M >> K;
for (int i = ; i < M; ++i)
{
cin >> sch.quto;
school.push_back(sch);
}
for (int i = ; i < N; ++i)
{
cin >> node.Ge >> node.Gt;
node.G = node.Ge + node.Gt;
node.id = i;
for (int j = ; j < K; ++j)
{
int t;
cin >> t;
node.choice[j] = t;//志愿学校
}
applicant.push_back(node);
}
sort(applicant.begin(), applicant.end(), cmp);
applicant[].rank = ;
for (int i = ; i < N; ++i)//排名
{
if (applicant[i].G == applicant[i - ].G && applicant[i].Ge == applicant[i - ].Ge)
applicant[i].rank = applicant[i - ].rank;
else
applicant[i].rank = i + ;
}
for (int i = ; i < N; ++i)//按学生选学校
{
for (int j = ; j < K; ++j)
{
int t = applicant[i].choice[j];
if (school[t].quto == && (school[t].admin.end() - )->second == applicant[i].rank)//排名相同可以超额
{
school[t].admin.push_back(make_pair(applicant[i].id, applicant[i].rank));//超额录取
break;
}
else if (school[t].quto == )
continue;//面试下一所学校,该学校满额
else
{
school[t].admin.push_back(make_pair(applicant[i].id, applicant[i].rank));//正常录取
school[t].quto--;//名额减少
break;
}
}
}
for (int i = ; i < M; ++i)
{
sort(school[i].admin.begin(), school[i].admin.end());
for (int j = ; j < school[i].admin.size(); ++j)
cout << school[i].admin[j].first << (j == school[i].admin.size() - ? "" : " ");
cout << endl;
}
return ;
}

PAT甲级——A1080 Graduate Admission的更多相关文章

  1. pat 甲级 1080. Graduate Admission (30)

    1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...

  2. PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)

    1080 Graduate Admission (30 分)   It is said that in 2011, there are about 100 graduate schools ready ...

  3. PAT甲级1080 Graduate Admission【模拟】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...

  4. A1080. Graduate Admission

    It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...

  5. PAT_A1080#Graduate Admission

    Source: PAT A1080 Graduate Admission (30 分) Description: It is said that in 2011, there are about 10 ...

  6. 1080 Graduate Admission——PAT甲级真题

    1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...

  7. PAT 1080 Graduate Admission[排序][难]

    1080 Graduate Admission(30 分) It is said that in 2011, there are about 100 graduate schools ready to ...

  8. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  9. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

随机推荐

  1. springboot整合thymeleaf手动渲染

    Thymeleaf手动渲染 为提高页面访问速度,可缓存html页面,客户端请求从缓存获取,获取不到再手动渲染 在spring4下 @Autowired ThymeleafViewResolver th ...

  2. 一点响应式Web设计与实现思路

    摘要: 是否还在为你的应用程序适配PC端,移动端,平板而苦苦思索呢,是否在寻找如何一套代码适配多终端方式呢,是否希望快速上手实现你的跨终端应用程序呢,是的话,那就看过来吧,本文阐述响应式UI设计相关理 ...

  3. Linux queue.h之TAILQ队列分析

    转自 这两天想看看memcached的实现,所以先学习了libevent,使用起来还是比较简单的,其实是对select/poll/kqueue等的封装,学习libevent过程中又遇到了linux下队 ...

  4. 一个有关group by的错误

    事例:查询有奖金的每个部门的部门名和部门的领导编号和该部门的最低工资 SELECT department_name,MIN(salary),departments.manager_idFROM dep ...

  5. [JZOJ3692] 【SRM 611】ElephantDrinking

    题目 题目大意 我真的不知道怎么用简短的语言表述出来-- 直接看题目吧-- 正解 假设只有左边和上边延伸过来的,那似乎很好办:设\(f_{i,j}\)表示左上方到\((i,j)\)所形成的矩形中,如果 ...

  6. js基础(条件语句 循环语句)

    条件语句 if语句块的语法形式如下: //只有两种情况下if(条件){要执行的语句块;}else{要执行的语句块;} //多种情况下if(条件){要执行的语句块;}else if(条件){要执行的语句 ...

  7. 配置文件一web.xml

    前言 web.xml中标签的加载顺序:<context-param> > <listener> (spring的相关工作) > filter >servlet ...

  8. thinkphp 原样输出

    可以使用literal标签来防止模板标签被解析,例如: 大理石构件 <literal> <if condition="$name eq 1 "> value ...

  9. dos中文乱码怎么办?

    最简单的方法: 通过 chcp命令改变代码页,UTF-8的代码页为65001 即chcp 65001 chcp 65001  就是换成UTF-8代码页 chcp 936 可以换回默认的GBK chcp ...

  10. spring Cache + Redis 开发数据字典以及自定义标签

    一.数据库表结构 1.  分类表:dict_type 2.  子项表:dict_entry 二.页面维护功能示意图: 1.  分类管理 点击子项管理进入子项管理页面 2.子项管理 三.数据字典添加到缓 ...