1080. Graduate Admission (30)

来源:互联网 发布:windows 32位升级64位 编辑:程序博客网 时间:2024/06/06 02:17

1080. Graduate Admission (30)

时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

It is said that in 2013, there were 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 GE, and the interview grade GI. The final grade of an applicant is (GE + GI) / 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 GE. 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 GE and GI, 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 32 1 2 2 2 3100 100 0 1 260 60 2 3 5100 90 0 3 490 100 1 2 090 90 5 1 380 90 1 0 280 80 0 1 280 80 0 1 280 70 1 3 270 80 1 2 3100 100 0 2 4
Sample Output:
0 1035 6 72 81 4
高考录取模拟
输入:
N学生总数(编号0~N-1)  M学校总数(代号0~M-1)    K(每个学生可以填的志愿个数)
goal0  goal1……goalM-1   (按照代号0~M-1顺序给出的M个学校预录取的人数
GE书面分     GI面试分   第一志愿  第二志愿 ……第K志愿 (接着N行,按照学生编号0~N-1给出)
……

输出(M行,每行代表0~M-1的学校的录取学生编号,并且每行按编号从小到大排序,如果这个学校一个也没有录取,那么输出一行空行)



要求
先把学生根据     总分 (GE书面分+GI面试分)/2 从高到低排序
                                       如果总分一样,根据GE书面分从高到低排序;
                                                         如果一样排名一样
录取根据以上从高到低的排名开始学生一个个进行:
 第一志愿开始,如果【这个学校未录满人数】或者【这个学校已经录满人数但是录取的后面的排名正好和这名学生一样】,那么这名学生被这个学校录取。
                                否则,看看这名学生的下一个志愿……
如果这名学生的所有志愿都没有录取这名学生,那么这名学生被退档; 样例中的9就被退档了。

评测结果

时间结果得分题目语言用时(ms)内存(kB)用户8月17日 12:19答案正确301080C++ (g++ 4.7.2)723632datrilla

测试点

测试点结果用时(ms)内存(kB)得分/满分0答案正确135218/181答案正确13842/22答案正确12482/23答案正确13842/24答案正确7236324/45答案正确13042/2

#include<iostream>  #include<vector>  #include<algorithm>using namespace std;  struct sclist{  int GE;  int GI;  int goal;  vector<int>stulist;  };void readln(vector<vector<int>>*applicant,vector<sclist>*schools,int N,int M,int K){  int index,Ge,Gi;  for (index = 0; index < M; index++)      cin>>(*schools)[index].goal;   for (index = 0; index < N; index++)  {    cin >> Ge >> Gi;     (*applicant)[index].push_back(index);    (*applicant)[index].push_back(Ge);    (*applicant)[index].push_back(Gi);    Gi = K;    while (Gi--)    {      cin >> Ge;      (*applicant)[index].push_back(Ge);    }  }  }bool appliCmp(const vector<int>&A, const vector<int>&B){  if (A[2] + A[1] != B[2] + B[1])return A[2] + A[1] > B[2] + B[1];  else return A[1] > B[1];}  bool sortlist(const int &A, const int &B){  return A < B;}void dispaly(vector<sclist>*schools, int M){  for (int index = 0; index < M; index++)  {    if ((*schools)[index].stulist.size() > 0)    {      sort((*schools)[index].stulist.begin(), (*schools)[index].stulist.end(), sortlist);      cout << (*schools)[index].stulist[0];      for (vector<int>::iterator iter = (*schools)[index].stulist.begin()+1; iter != (*schools)[index].stulist.end(); iter++)         cout << " " << (*iter);     }    cout << endl;  }}int main(){  int N, M, K,index;  cin >> N >> M >> K;  vector<vector<int>>applicant(N);  vector<sclist>schools(M);  readln(&applicant, &schools, N, M, K);   sort(applicant.begin(),applicant.end(),appliCmp);  for (index = 0; index < N; index++)  {    int inner = 3,temp;    bool admit = false;    for (; inner < K+3&&!admit; inner++)    {      temp = applicant[index][inner];      if (schools[temp].goal > schools[temp].stulist.size())      {        schools[temp].stulist.push_back(applicant[index][0]);        schools[temp].GE = applicant[index][1];        schools[temp].GI = applicant[index][2];        admit = true;      }      else if (applicant[index][1] == schools[temp].GE&&applicant[index][2] == schools[temp].GI)      {        schools[temp].stulist.push_back(applicant[index][0]);          admit = true;      }     }  }  dispaly(&schools, M);    system("pause");  return 0;}
0 0