Topic 1005:graduate Admission (admission algorithm)

Source: Internet
Author: User

Title Link: http://ac.jobdu.com/problem.php?pid=1005

Detailed Links: https://github.com/zpfbuaa/JobduInCPlusPlus

Reference code:

////1005 Graduate Admission.cpp//Jobdu////Created by Pengfei_zheng on 27/04/2017.//copyright©2017 Pengfei_zheng. All rights reserved.//#include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>#include<cmath>#defineCHOOSE 6#defineMax_size 40001#defineSCHOOL 101using namespacestd;intN, M, K;structapply{intGE; intgi; DoubleGF; intChoose[choose]; intID; BOOL operator< (ConstApply &a)Const{        if(GF! =A.GF) {            returnGF >A.GF; }        Else if(GE! =a.ge) {            returnGE >a.ge; }        Else {            returnGE >a.ge; }    }};structschool{intquota; intRealnum; intappid[max_size];}; Apply Apply[max_size]; School School[school]; intMain () { while(SCANF ("%d%d%d", &n,&m,&k)! =EOF) {                  for(inti =0; I < m; i++) {scanf ("%d",&School[i].quota); School[i].realnum=0; }         for(inti =0; I < n; i++) {scanf ("%d%d",&apply[i].ge,&apply[i].gi); APPLY[I].GF=(Double) (APPLY[I].GE+APPLY[I].GI)/2.0;  for(intj =0; J < K; J + +) {scanf ("%d",&Apply[i].choose[j]); } apply[i].id=i; } sort (Apply,apply+N); intSID;  for(inti =0; I < n; i++){             for(intj =0; J < K; J + +) {SID=Apply[i].choose[j]; if(School[sid].quota >0) {School[sid].appid[school[sid].realnum]=i; School[sid].realnum++; School[sid].quota--;  Break; }                Else{                    intLastID = school[sid].appid[school[sid].realnum-1]; if(APPLY[I].GF = = APPLY[LASTID].GF && apply[i].ge = =apply[lastid].ge) {School[sid].appid[school[sid].realnum]=i; School[sid].realnum++; School[sid].quota--;  Break; }                }            }        }                  for(inti =0; I < m; i++){             for(intj =0; J < School[i].realnum; J + +) {School[i].appid[j]=apply[school[i].appid[j]].id; }        }                  for(inti =0; I < m; i++){            if(school[i].realnum==0) {printf ("\ n"); }            Else if(school[i].realnum==1) {printf ("%d\n", school[i].appid[0]); }            Else{sort (school[i].appid,school[i].appid+school[i].realnum); BOOLFirst =true;  for(intj =0; J < School[i].realnum; J + +){                    if(first==true) { First=false; }                    Else{printf (" "); } printf ("%d", School[i].appid[j]); } printf ("\ n"); }        }    }    return 0;}/************************************************************** problem:1005 User:zpfbuaa language:c++ R esult:accepted time:0 Ms memory:19180 kb****************************************************************/

Topic 1005:graduate Admission (admission algorithm)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.