zoukankan      html  css  js  c++  java
  • 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 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

      1 #include<stdio.h>
      2 #include<vector>
      3 #include<algorithm>
      4 using namespace std;
      5 
      6 struct stu
      7 {
      8     int Gin;
      9     int id;
     10     double GAvg;
     11     int rank;
     12     vector<int> app;
     13 };
     14 
     15 vector< stu > Student;
     16 vector<int> School[101];
     17 bool isfull[101];
     18 
     19 int cmp2(int a,int b )
     20 {
     21     return a < b;
     22 }
     23 
     24 int cmp(stu a,stu b)
     25 {
     26     if(a.GAvg != b.GAvg) return a.GAvg > b.GAvg;
     27     return a.Gin > b.Gin;
     28 }
     29 
     30 int main()
     31 {
     32     int stunum,schoolnum,appcnum;
     33     vector<int> admit;
     34     scanf("%d%d%d",&stunum,&schoolnum,&appcnum);
     35     int i;
     36     for(i = 0 ; i < schoolnum ; i++ )
     37     {
     38         int tem ;
     39         scanf("%d",&tem);
     40         admit.push_back(tem);
     41     }
     42 
     43 
     44     for(i = 0; i < stunum ; i++)
     45     {
     46         int temGin,temGfu;
     47         scanf("%d%d",&temGin,&temGfu);
     48         stu temstu;
     49         temstu.id = i;
     50         temstu.Gin = temGin;
     51         temstu.GAvg = (double)(temGin + temGfu)*1.0/2;
     52         for(int j=0 ; j < appcnum ; j++)
     53         {
     54             int apptem;
     55             scanf("%d",&apptem);
     56             temstu.app.push_back(apptem);
     57         }
     58 
     59         Student.push_back(temstu);
     60     }
     61 
     62 
     63     sort(Student.begin(),Student.end(),cmp);
     64 
     65     Student[0].rank = 1;
     66 
     67     for(i = 1 ; i < stunum ; i++)
     68     {
     69         if(Student[i-1].GAvg == Student[i].GAvg  && Student[i].Gin == Student[i-1].Gin)
     70         {
     71             Student[i].rank = Student[i - 1].rank;
     72         }
     73         else
     74         {
     75             Student[i].rank = i + 1;
     76         }
     77     }
     78 
     79     for(i = 0 ; i < stunum ; i ++)
     80     {
     81         int index = Student[i].rank;
     82         vector<stu> StudentTem;
     83         int j;
     84         while( i < stunum )
     85         {
     86             if(Student[i].rank == index)
     87                 StudentTem.push_back(Student[i]);
     88             else
     89             {
     90                 break;
     91             }
     92             i ++;
     93         }
     94         --i;
     95 
     96         for(j = 0 ; j < StudentTem.size() ; j ++)
     97         {
     98             for(int k = 0 ; k < StudentTem[j].app.size() ; k ++)
     99             {
    100                 if(!isfull[StudentTem[j].app[k]])
    101                 {
    102                     School[ StudentTem[j].app[k] ].push_back(StudentTem[j].id);
    103                     break;
    104                 }
    105             }
    106         }
    107 
    108         for(j = 0 ; j < schoolnum ; j ++)
    109         {
    110             if(School[j].size() >= admit[j] )
    111                 isfull[j] = 1;
    112         }
    113     }
    114 
    115 
    116     for(i = 0 ; i < schoolnum ; i++)
    117     {
    118         bool fir = 1;
    119         sort(School[i].begin(),School[i].end(),cmp2);
    120         for(int j = 0 ; j < School[i].size() ; j ++)
    121         {
    122             if(fir)
    123             {
    124                 printf("%d",School[i][j]);
    125                 fir = 0;
    126             }
    127             else
    128             {
    129                 printf(" %d",School[i][j]);
    130             }
    131         }
    132         printf("
    ");
    133     }
    134 
    135     return 0;
    136 
    137 }
  • 相关阅读:
    移动桌面文件
    软件项目经理素质能力的必备要求
    如何管理时间
    《明日歌》
    浏览网页出现iexplore.exe应用程序错误为:"0x03e620b0"指令引用的"0x00000000"内存.该内存不能为"read"?
    css网站布局学习笔记
    因为爱,人生除了理智,还有情感!
    35岁之前成功的12条黄金法则
    VS2005中没有DataGrid控件的解决方案
    先装VS2005再装IIS,出现访问IIS元数据库失败解决方案
  • 原文地址:https://www.cnblogs.com/xiaoyesoso/p/4307172.html
Copyright © 2011-2022 走看看