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. Linux安全审计-基础篇

    安全审计这块我能想到的有两种方案可以解决,一种是在Linux中配置实现,一种是使用Python开发堡垒机实现,我先实现了第一种比较简单的:后面会开发堡垒机:   一.首先我们需要在/etc/profi ...

  2. vue echart例——柱状图及高度自适应

    1.安装 npm install echarts -s 2.例——点击tab切换时柱状图重绘,高度根据返回数据设置. <template> <div> <ul id=&q ...

  3. Python学习笔记(三)——文件系统中的常用方法

    OS模块中关于文件/目录常用的函数使用方法 函数名 使用方法 getcwd() 返回当前工作目录 chdir() 改变工作目录 listdir(path='.') 列举指定目录中的文件名('.'表示当 ...

  4. Yii2 在php 7.2环境下运行,提示 Cannot use ‘Object’ as class name

    出错原因是: Object是php7.2中的保留类名,不可以使用Object作为类的名称. The object name was previously soft-reserved in PHP 7. ...

  5. mysql 存储过程学习 汇总

    存储过程框架 DEMILITER $$ -- 重定义符 DROP PROCEDURE IF EXISTS store_procedure$$ -- 如果存在此名的存储过程,先删除 CREATE PRO ...

  6. Erlang学习记录:app demo

    目录结构 │ Emakefile │ make.bat │ start.bat ├─config │ config.config │ server.app ├─ebin │ wulin_app.bea ...

  7. 【未完成】Jmeter接口自动化测试:参数化设置

    1. 从CSV文件读取参数 创建一个CVS文件,文件第一行不写参数名,直接从参数值开始,每一列代表一个参数 在测试计划或者线程组中,添加一个配置元件-->CSV 数据文件设置 Filename: ...

  8. 线段树+欧拉函数——cf1114F

    调了半天,写线段树老是写炸 /* 两个操作 1.区间乘法 2.区间乘积询问欧拉函数 欧拉函数计算公式 phi(mul(ai))=mul(ai) * (p1-1)/p1 * (p2-1)/p2 * .. ...

  9. Vue+Iview+Node 登录demo

    1.相关组件安装 axios  iview  js-cookie  crypto-js 2.子父组件传值.监听窗体大小改变.记住密码 .自定义组件(事件 .props) created:实例已经创建完 ...

  10. DELPHI实现类似仿360桌面的程序界面

    1.窗体半透明: Alphablend属性为true;Alphablendvalue的值为100 2.窗体透明: formCreate: Self.TransparentColor := True;S ...