#include<stdio.h>#include<string.h>#include<algorithm>Usingnamespace Std;int want[106];Number of students enrolled in each schoolstruct student{int ge,gi,sum,rank,id;int prefer[6];BOOL R;On behalf of the student's admission}stu[40066];BOOL CMP (Student a,student b) {if (a.sum!=b.sum)Return a.sum>b.sum;Elsereturn a.ge>b.ge;}int main () {memset (STU,0,sizeof (STU)); Fill (want,want+106,-1);Number of students in each school initial set-1int n,m,k;N candidates, M school, K volunteer scanf ("%d%d%d", &n,&m,&k);Forint i=0; I<m; ++i)Enter the number of schools enrolled scanf ("%d", &want[i]);Forint i=0; I<n; ++i) {scanf ("%d%d", &stu[i]. GE, &stu[i]. GI);Fill in the score stu[i].sum=stu[i]. Ge+stu[i]. HitFill in the total score stu[i].id=i;Fill in the numberForint j=0; j<k; ++J) {int tmp=-1; scanf"%d", &tmp);Fill in the volunteer stu[i].prefer[tmp]=1; }} sort (stu,stu+n,cmp); stu[0].rank=1;Forint i=1; I<n; ++i)Fill in Sort {if (stu[i].sum==stu[i-1].sum && Stu[i]. ge==stu[i-1]. GE) stu[i].rank=stu[i-1].rank;else stu[i].rank=i+1; }School priority option Law (not in accordance with test instructions)Forint i=0; I<m; ++i)Export admission information for each school {int top=0;Exception admission for output and rankingint kongge=0;Control the output of a spaceForint j=0; J<n; ++J) {if (Stu[j]. r==0 && stu[j].prefer[i]==1 && (want[i]>0 | | want[i]==0 && stu[j].rank==top)) //the student was not admitted, the student to apply for the school, the school is still hiring, or the school is full, only the students to tie this position {if (kongge!= 0) printf ( " "%d", Stu[j]. ID); Kongge=1; top=stu[j].rank; //records the candidate's ranking Stu[j]. R=1; //mark candidates have dropped files--want[i]; //number of students required-1}} printf ( "\n");} return 0;}
pat:1080. Graduate Admission (30) part of the error (admission is school-oriented rather than examinee-led error)