zoj 3705 Applications(较复杂的模拟)

1、http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3705

2、题目大意:

有t组样例,每组样例有n个人,要从这n个人中选m个人,按照给定的计算方式给每个人算出她应得的分数,输出分数前m大的即可,注意max(),c++类库里的不能比较double,所以要重写,别的没有陷阱了

5 3  //5个人要从中选择3个人
3 1001 1002 1003   //MaoMao Selection上有3道题目,后边3个数分别是题号
4 1004 1005 1006 1007    //Old Surgeon Contest上有4道题目,后边是没道题目的题号
3  //有3个队伍
MagicGirl!!! 3   //第一个队伍的队名和rank
Sister's_noise 2   //第二个队伍的队名和rank
NexusHD+NexusHD 1   //第三个队伍的队名和rank
Edward EKaDiYaKanWen M 5 3   //第一个人的姓名,属于的队名,性别,做对了5道题目,有3个rank
1001 1003 1005 1007 1009
1800 1800 1800
FScarlet MagicGirl!!! F 3 5
1004 1005 1007
1300 1400 1500 1600 1700
A NexusHD+NexusHD M 0 0


B None F 0 0


IamMM Sister's_noise M 15 1
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
3000
3、题目:

Applications

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Recently, the ACM/ICPC team of Marjar University decided to choose some new members from freshmen to take part in the ACM/ICPC competitions of the next season. As a traditional elite university in ACM/ICPC, there is no doubt that application forms will fill up the mailbox. To constitute some powerful teams, coaches of the ACM/ICPC team decided to use a system to score all applicants, the rules are described as below. Please note that the score of an applicant is measured by pts, which is short for "points".

1. Of course, the number of solved ACM/ICPC problems of a applicant is important. Proudly, Marjar University have a best online judge system called Marjar Online Judge System V2.0, and in short, MOJ. All solved problems in MOJ of a applicant will be scored under these rules:

  • (1) The problems in a set, called MaoMao Selection, will be counted as 2.5 pts for a problem.
  • (2) The problems from Old Surgeon Contest, will be counted as 1.5 pts for a problem.There is no problem in MaoMao Selection from Old Surgeon Contest.
  • (3) Besides the problem from MaoMao Selection and Old Surgeon Contest, if the problem's id is a prime, then it will be counted as 1 pts.
  • (4) If a solved problem doesn't meet above three condition, then it will be counted as 0.3 pts.

2. Competitions also show the strength of an applicant. Marjar University holds the ACM/ICPC competition of whole school once a year. To get some pts from the competition, an applicant should fulfill rules as below:

  • The member of a team will be counted as 36 pts if the team won first prize in the competition.
  • The member of a team will be counted as 27 pts if the team won second prize in the competition.
  • The member of a team will be counted as 18 pts if the team won third prize in the competition.
  • Otherwise, 0 pts will be counted.

3. We all know that some websites held problem solving contest regularly, such as JapanJam, ZacaiForces and so on. The registered member of JapanJam will have a rating after each contest held by it. Coaches thinks that the third highest rating in JapanJam of an applicant is good to show his/her ability, so the scoring formula is:

Pts = max(0, (r - 1200) / 100) * 1.5

Here r is the third highest rating in JapanJam of an applicant.

4. And most importantly - if the applicant is a girl, then the score will be added by 33 pts.

The system is so complicated that it becomes a huge problem for coaches when calculating the score of all applicants. Please help coaches to choose the best M applicants!

Input

There are multiple test cases.

The first line of input is an integer T (1 ≤T ≤ 10), indicating the number of test cases.

For each test case, first line contains two integers N (1 ≤N ≤ 500) - the number of applicants and M (1 ≤MN) - the number of members coaches want to choose.

The following line contains an integer R followed by R (0 ≤R ≤ 500) numbers, indicating the id of R problems in MaoMao Selection.

And then the following line contains an integer S (0 ≤S ≤ 500) followed by S numbers, indicating the id of S problems from Old Surgeon Contest.

The following line contains an integer Q (0 ≤Q ≤ 500) - There are Q teams took part in Marjar University's competition.

Following Q lines, each line contains a string - team name and one integer - prize the team get. More specifically, 1 means first prize, 2 means second prize, 3 means third prize, and 0 means no prize.

In the end of each test case, there are N parts. In each part, first line contains two strings - the applicant's name and his/her team name in Marjar University's competition, a char sex - M for male, F for female and two integers P (0 ≤P ≤ 1000) - the number of problem the applicant solved, C (0 ≤C ≤ 1000) - the number of competitions the applicant have taken part in JapanJam.

The following line contains P integers, indicating the id of the solved problems of this applicant.

And, the following line contains C integers, means the rating for C competitions the applicant have taken part in.

We promise:

  • The problems' id in MaoMao Selection, Old Surgeon Contest and applicant's solving list are distinct, and all of them have 4 digits (such as 1010).
  • All names don't contain spaces, and length of each name is less than 30.
  • All ratings are non-negative integers and less than 3500.
Output

For each test case, output M lines, means that M applicants and their scores. Please output these informations by sorting scores in descending order. If two applicants have the same rating, then sort their names in alphabet order. The score should be rounded to 3 decimal points.

Sample Input
1
5 3
3 1001 1002 1003
4 1004 1005 1006 1007
3
MagicGirl!!! 3
Sister's_noise 2
NexusHD+NexusHD 1
Edward EKaDiYaKanWen M 5 3
1001 1003 1005 1007 1009
1800 1800 1800
FScarlet MagicGirl!!! F 3 5
1004 1005 1007
1300 1400 1500 1600 1700
A NexusHD+NexusHD M 0 0


B None F 0 0


IamMM Sister's_noise M 15 1
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
3000
Sample Output
FScarlet 60.000
IamMM 44.300
A 36.000
4、AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1005];
int b[1005];
char tname[150];
int t,n,m,r,q,s;
struct node
{
    char name[150];
    int rank;
} team[1005];
struct node1
{
    char pname[150];
    double pt;
} p[1005];
int cmp(int a,int b)
{
    return a>b;
}
int find()
{
    for(int i=0; i<q; i++)
    {
        if(strcmp(team[i].name,tname)==0)
            return team[i].rank;
    }
    return 0;
}
int find1(int aa)
{
    for(int i=0; i<r; i++)
    {
        if(aa==a[i])
            return 1;
    }
    return 0;
}
int find2(int aa)
{
    for(int i=0; i<s; i++)
    {
        if(aa==b[i])
            return 1;
    }
    return 0;
}
double Max(double i,double j)
{
    if(i>j)
    return i;
    return j;
}
bool visit[20007];
int prime[20007];
int num=0;
void init_prim(int n)//prime存的是下标,visit存的是数。visit[5]==true。
{
    memset(visit,true,sizeof(visit));
    for(int i=2; i<=n; ++i)
    {
        if(visit[i] ==true)
        {
            num++;
            prime[num] =i;
        }
        for(int j=1; ((j<=num)&&(i*prime[j] <=n)); ++j)
        {
            visit[i*prime[j] ]=false;
            if(i%prime[j] ==0) break;
        }
    }
}
int cmp1(node1 j,node1 k)
{
    if(j.pt==k.pt)
    return strcmp(j.pname,k.pname)<0;
//        return j.pname<k.pname;
    return j.pt>k.pt;
}
int main()
{
    char sex;
    int f[1005],e;
    init_prim(10000);
    while(scanf("%d",&t)!=EOF)
    {
        while(t--)
        {
            memset(a,0,sizeof(a));
            memset(b,0,sizeof(b));
            scanf("%d%d",&n,&m);
            scanf("%d",&r);
            for(int i=0; i<r; i++)
            {
                scanf("%d",&a[i]);
            }
            scanf("%d",&s);
            for(int i=0; i<s; i++)
                scanf("%d",&b[i]);
            scanf("%d",&q);
            for(int i=0; i<q; i++)
            {
                scanf("%s%d",team[i].name,&team[i].rank);
            }
            int c,d;

            for(int i=0; i<n; i++)
            {
                double sum=0;
                char w;
                scanf("%s%s%c%c%d%d",p[i].pname,tname,&w,&sex,&c,&d);
                // printf("***%s %s %c %d %d\n",p[i].pname,tname,sex,c,d);
                if(sex=='F')
                    sum+=33;
                int ans=find();
                if(ans==1)
                    sum+=36;
                else if(ans==2)
                    sum+=27;
                else if(ans==3)
                    sum+=18;
                else
                    sum+=0;
                for(int j=0; j<c; j++)
                {
                    scanf("%d",&e);
                    if(find1(e))
                    {
                        sum+=2.5;
                    }
                    else if(find2(e))
                    {
                        sum+=1.5;
                    }
                    else if(visit[e])
                    {
                        sum+=1;
                    }
                    else
                    {
                        sum+=0.3;
                    }
                }
                memset(f,0,sizeof(f));
                for(int j=0; j<d; j++)
                {
                    scanf("%d",&f[j]);
                }
                sort(f,f+d,cmp);
//                double MAX=1e-9;
//                if((f[2]*1.0-1200.0)/100.0>MAX)
//                    MAX=(f[2]-1200)/100;
//                    else
//                    MAX=0.0;
//                sum+=(MAX*1.5);
                sum+=(Max(0.0, (f[2]*1.0 - 1200.0) / 100.0) * 1.5);
                p[i].pt=sum;
            }
            sort(p,p+n,cmp1);
            for(int i=0; i<m; i++)
            {
                printf("%s %.3f\n",p[i].pname,p[i].pt);
            }
        }
    }
    return 0;
}
/*
1
5 3
3 1001 1002 1003
4 1004 1005 1006 1007
3
MagicGirl!!! 3
Sister's_noise 2
NexusHD+NexusHD 1
Edward EKaDiYaKanWen M 5 3
1001 1003 1005 1007 1009
1800 1800 1800
FScarlet MagicGirl!!! F 3 5
1004 1005 1007
1300 1400 1500 1600 1700
A NexusHD+NexusHD M 0 0


GScarlet MagicGirl!!! F 3 5
1004 1005 1007
1300 1400 1500 1600 1700
IamMM Sister's_noise M 15 1
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
3000
*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值