The Android University ACM Team Selection Contest
2013-05-25 21:08
316 查看
The Android University ACM Team Selection Contest
Time Limit: 1000MS Memory limit: 65536K
题目描述
Now it's 20000 A.D., and the androids also participate in the ACM Inter-national Collegiate Programming Contest (ACM/ICPC). In order to select the members of Android University ACM/ICPC Training Camp, a contest was held. There were N teams competing in thecontest, among which there might be some teams whose members are all girls (they are called all-girls teams). Some of the N teams will be selected, then all the members of those teams are selected as the members of the training camp.
To be selected, one team has to solve at least one problem in the contest. The the top M teams who solved at least one problem are selected (If there are less than M teams solving at least one problem, they are all selected).
There is an bonus for the girls - if top M teams contains no all-girls teams,the highest ranked all-girls team is also selected (together with the M top teams), provided that they have solved at least one problem.
Recall that in an ACM/ICPC style contest, teams are ranked as following:
1. The more problems a team solves, the higher order it has.
2. If multiple teams have the same number of solved problems, a team with a smaller penalty value has a higher order than a team with a
larger penalty value.
Given the number of teams N, the number M defined above, and each team's name, number of solved problems, penalty value and whether it's an all-girls team, you are required to write a program to find out which teams are selected.
输入
The input has multiple test cases. The first line of the input contains one integer C, which is the number of test cases.Each test case begins with a line contains two integers, N (1 <= N <=10^4) and M (1 <= M <= N), separated by a single space. Next will be N lines, each of which gives the information about one specific competing team.Each of the N lines contains a string S
(with length at most 30, and consists of upper and lower case alphabetic characters) followed by three integers, A(0 <= A <= 10), T (0 <= T <= 10) and P (0 <= P <= 5000), where S is the name of the team, A indicates whether the team is an all-girls team (it
is not an all-girls team if Ai is 0, otherwise it is an all-girls team). T is the number of problems the team solved, and P is the penalty value of the team.
The input guarantees that no two teams who solved at least one problem have both the same T and P.
输出
For each test case, print one line containing the case number (starting from 1). Then, output the selected teams' names by the order they appear in the input, one on each line. Print a blank line between the output for two test cases. Refer to the Sample Outputsection for details.
示例输入
3 5 3 AU001 0 0 0 AU002 1 1 200 AU003 1 1 30 AU004 0 5 500 AU005 0 7 1000 2 1 BOYS 0 10 1200 GIRLS 10 1 290 3 3 red 0 0 0 green 0 0 0 blue 0 1 30
示例输出
Case 1: AU003 AU004 AU005 Case 2: BOYS GIRLS Case 3: blue 3 3
提示
来源
山东省第二届ACM大学生程序设计竞赛学习了一下qsort,应用了一下,没提交,感觉应该对吧。
#include<stdio.h> #include<string.h> #include<stdlib.h> struct node { char name[35]; int sex,b,c,num; } h[100010]; int cmp1(const void *p,const void *q) { if(((struct node *)p)->b-((struct node *)q)->b==0) return(((struct node *)p)->c-((struct node *)q)->c); else return(((struct node *)q)->b-((struct node *)p)->b); } int cmp2(const void *p,const void *q) { return(((struct node *)p)->num-((struct node *)q)->num); } int main() { int t,n,m,i,k,g; while(~scanf("%d",&t)) { for(k=1; k<=t; k++) { g=0; scanf("%d%d",&n,&m); for(i=0; i<n; i++) { scanf("%s%d%d%d",h[i].name,&h[i].sex,&h[i].b,&h[i].c); h[i].num=i; if(h[i].b) g=1; } qsort(h,n,sizeof(h[0]),cmp1); qsort(h,m,sizeof(h[0]),cmp2); printf("Case %d:\n",k); for(i=0; i<m; i++) { if(h[i].b) { printf("%s\n",h[i].name); if(h[i].sex) g=0; } } if(g) { for(i=0; i<n; i++) { if(h[i].sex) { printf("%s\n",h[i].name); break; } } } printf("\n"); } } return 0; }
相关文章推荐
- 山东省第二届ACM大学生程序设计竞赛:The Android University ACM Team Selection Contest
- 山东省第二届ACM省赛题——The Android University ACM Team Selection Contest
- SDUT 2162-The Android University ACM Team Selection Contest(模拟)
- 山东省第二届ACM大学生程序设计竞赛 The Android University ACM Team Selection Contest
- sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
- 山东省第二届ACM省赛 The Android University ACM Team Selection Contest
- [2011山东省第二届ACM大学生程序设计竞赛]——The Android University ACM Team Selection Contest
- 2017 Multi-University Training Contest - Team 7:1003. Color the chessboard(...)
- 【ZOJ3956 The 17th Zhejiang University Programming Contest I】【01背包】Course Selection System 公式最大化
- hdu 6051 If the starlight never fade [欧拉函数] [2017 Multi-University Training Contest - Team 2]
- 2017 Multi-University Training Contest - Team 8 Fleet of the Eternal Throne
- 2017 Multi-University Training Contest - Team 8:Fleet of the Eternal Throne(AC自动机)
- 2017 Multi-University Training Contest - Team 2 1001 Is Derek lying?
- hdu 6047 Maximum Sequence(2017 Multi-University Training Contest - Team 2)
- hdu 6045 Is Derek lying?(2017 Multi-University Training Contest - Team 2)
- 2017 Multi-University Training Contest - Team 1 :Function
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- 2017 Multi-University Training Contest - Team 2 hdu6050 Funny Function 矩阵快速幂
- 2017 Multi-University Training Contest - Team 2 1009 HDU 6053 TrickGCD(分段 容斥)
- The 37th ACM/ICPC Asia Regional ChangChun Site Online Contest - K USACO ORZ