题目我就不放了,这是一道和师兄帮帮忙 同等恶心的难题。。。

首先udebug的数据是有问题的,不符合题目描述。当然我们可以修改写法使得udebug的数据能够过。

然后,udebug的数据不全,有几个重要的问题它没有显现出来,分别是:

1。如果一个人是业余选手,那么在输出了总分之后就要换行,不能有多余空格。

2.。如果是最后一组样例,输出完成后,不应该输出换行符。

3.重要!题目的最后一句话理解,Only the low 70 non-amateur places and ties earn prize money. For example, if 75 players make the 36-hole cut, it is possible for 5 of them not to earn prize money, assuming none of the players making the cut are amateurs.。

并不是说奖金只发70份,说的是和第70份奖金并列的人如果不是业余选手,都可以拿到奖金;之后的人没有奖金。

做了两天两夜,wa了15次,在这里感谢另一篇关于这道题的博客链接

博主的数据,我的这三个错就是根据这个数据改出来的。

上代码:

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<sstream>
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const double eps=1e-8;
double total,percentage[71];
bool rank_has_t[150];int n,num_make_the_cut;
class Player
{
public:string name;int rd[6]={-1,-1,-1,-1,-1,-1},total=-6,total_12=-6,rank=-1,rank_money=-1;bool is_amateur;double money;string output_rank(void){for(int i=1;i<=4;i++)if(rd[i]==-1)return "";//This is man is DQ and has no rankstringstream ss;ss<<rank;if(rank_has_t[rank] && rank_money!=-1)ss<<'T';//Only those who earn money could got a 'T'return ss.str();}friend istream& operator >>(istream& in,Player& X){string input,input_score;getline(in,input);X.name=string(input,0,20);X.is_amateur=false;int id=19;while(X.name[id]==' ')id--;if(X.name[id]=='*')X.is_amateur=true;string score(input,20,12);stringstream ss(score);int cnt=1;while(ss>>input_score){if(input_score[0]=='D')break;else{X.rd[cnt]=stoi(input_score);cnt++;}}if(cnt!=5)for(;cnt<5;cnt++)X.rd[cnt]=-1;//This part can not be deleted for the sake of we use cin X.total_12=X.rd[1]+X.rd[2];X.total=X.total_12+X.rd[3]+X.rd[4];return in;}
};
Player P[150];
void readin(void)
{cin>>total;for(int i=1;i<=70;i++)cin>>percentage[i];cin>>n;scanf("\n");Player temp;for(int i=1;i<=n;i++){cin>>temp;P[i]=temp;}}
bool  cmp_first_2_round(Player X,Player Y)
{bool X_isdisqualified=false,Y_isdisqualified=false;for(int i=1;i<=2;i++){if(X.rd[i]==-1)X_isdisqualified=true;if(Y.rd[i]==-1)Y_isdisqualified=true;}if(X_isdisqualified && Y_isdisqualified)return false;if(X_isdisqualified)return false;if(Y_isdisqualified)return true;int X_rd=X.total_12,Y_rd=Y.total_12;//if both X and Y is not disqualified,then//calculate their sum score of round1 and round2return X_rd < Y_rd;
}bool cmp_last_2_round(Player X,Player Y)
{int X_round=0,Y_round=0;for(int i=1;i<=4;i++){if(X.rd[i]!=-1)X_round++;if(Y.rd[i]!=-1)Y_round++;}if(X_round!=Y_round)return X_round>Y_round;//If the program runs to this part,then X_round==Y_round//let us suppose X_round==Y_round!=4,there exists some lesson//whose grade is -1,but that does not affect our programif(X.total!=Y.total)return X.total<Y.total;//sort by alphabetic order(name)return X.name<Y.name;
}double calc_money(int i,int j,int cnt)//if rank_money is from i to j(the same total score)
{double total_percent=0;for(int k=i;k<=j;k++)total_percent+=percentage[k];total_percent/=cnt;return (total*total_percent)/100.0+eps;
}void output(void)
{printf("Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won\n");printf("-----------------------------------------------------------------------\n");for(int i=1;i<=num_make_the_cut;i++){bool flag=true;printf("%-21s%-10s",P[i].name.c_str(),P[i].output_rank().c_str()); for(int j=1;j<=4;j++)   {if(P[i].rd[j]==-1)//DQflag=false;if(flag)printf("%-5d",P[i].rd[j]);elseprintf("     ");}if(!flag)printf("DQ");else{if(P[i].rank_money!=-1)printf("%-10d",P[i].total);elseprintf("%d",P[i].total);//here,used to be -3d}if(P[i].rank_money==-1)printf("\n");else printf("$%9.2lf\n",P[i].money);}
}
int main(void)
{int T;cin>>T;while(T--){memset(rank_has_t,0,sizeof(rank_has_t));readin();sort(P+1,P+1+n,cmp_first_2_round);num_make_the_cut=0;while( num_make_the_cut<n && num_make_the_cut<=70){int id=num_make_the_cut+1;if( (P[id].rd[1]!=-1) && (P[id].rd[2]!=-1) )num_make_the_cut++;elsebreak;}if(num_make_the_cut>70 && n>70)//the loop exits because num_make_the_cut>70{num_make_the_cut=70;while( num_make_the_cut<n && P[num_make_the_cut+1].total_12==P[70].total_12 ){int id=num_make_the_cut+1;if( (P[id].rd[1]!=-1) && (P[id].rd[2]!=-1) )num_make_the_cut++;elsebreak;}}sort(P+1,P+num_make_the_cut+1,cmp_last_2_round);int rank=2,rank_money=2;P[1].rank=1;if(P[1].rd[3]!=-1 && P[1].rd[4]!=-1 && !P[1].is_amateur)P[1].rank_money=1;else{P[1].rank_money=-1;rank_money--;}int id_rank_money_70=-1;//This is the id of people whose rank_money is 70for(int i=2;i<=num_make_the_cut;i++,rank++)//calculate the rank{if(P[i].total==P[i-1].total)P[i].rank=P[i-1].rank;elseP[i].rank=rank;if(!P[i].is_amateur &&(P[i].rd[3]!=-1) &&(P[i].rd[4]!=-1)&& rank_money<=70 )//here ,I delete the setence rank_money<=70{P[i].rank_money=rank_money;if(rank_money==70)id_rank_money_70=i;rank_money++;}elseP[i].rank_money=-1;}if(id_rank_money_70!=-1){for(int i=id_rank_money_70;(i<=num_make_the_cut)&&(P[i].rank==P[id_rank_money_70].rank);i++)if(!P[i].is_amateur)P[i].rank_money=70;}int cnt=0,id=1,offset=0,rank_money_min,rank_money_max;//number of the same rankwhile(id<=num_make_the_cut){cnt=offset=0;//cnt is the number of players who got the moneyrank_money_min=500;rank_money_max=-100;while(id+offset<=num_make_the_cut && P[id+offset].rank==P[id].rank){if(P[id+offset].rank_money!=-1)//{cnt++;rank_money_min=min(rank_money_min,P[id+offset].rank_money);rank_money_max=max(rank_money_max,P[id+offset].rank_money);} offset++;}for(int i=id;i<id+offset;i++){if(P[i].rank_money!=-1)P[i].money=calc_money(rank_money_min,rank_money_max,cnt);elseP[i].money=-1;}if(cnt>1)rank_has_t[ P[id].rank ]=true;id+=offset;}output();if(T)printf("\n");}return 0;
}

Uva207 PGA Tour Prize Money相关推荐

  1. 207:PGA Tour Prize Money

    PGA Tour Prize Money 这道题太麻烦了,先放这儿,日后再说... #include<cstdio> #include<cstring> #include< ...

  2. 例题5-10 PGA巡回赛的奖金(PGA Tour Prize Money,ACM/ICPC World Finals 1990 UVa207)

    原题链接:https://vjudge.net/problem/UVA-207 分类:耐力 备注:排序和其他细节处理 前言:这是我第二次默写刘老师的代码了,真的崩溃,错一点点细节都不行,对着uDebu ...

  3. UVA 207 PGA Tour Prize Money

    题目链接:https://vjudge.net/problem/UVA-207 题目翻译摘自<算法禁赛入门经典> 题目大意 你的任务是为PGA(美国职业高尔夫球协会)巡回赛计算奖金.巡回赛 ...

  4. UVa 207 - PGA Tour Prize Money(模拟)

    分配PGA奖金的问题,题目不难,但是细节比较坑. 要注意数据的读入,排名带T的条件,奖金精度的控制等很多细节. #include<algorithm> #include<cstdio ...

  5. PGA Tour PRize Money(Uva 207)

    //生无可恋,看的别人的代码,有时间理解,20ms <code class="hljs cpp has-numbering"><span class=" ...

  6. UVa 207 - PGA Tour Prize Money

    时间限制:3.000秒 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&catego ...

  7. UVA - 207 PGA Tour Prize Money

    /*法一:代码借鉴修改自blog:http://blog.csdn.net/aozil_yang/article/details/50543965这个博客把思路和注意的地方说得很详细了,建议一看收获: ...

  8. 例题5-10 UVA 207 PGA Tour Prize Money PGA巡回赛的奖金

    这个题真是快把自己折磨疯了,在学校因为要复习,折腾了10天才AC,结果电脑出了点问题代码数据全部丢失,放假后又写了一遍,结果不断RE一天,唉! 这个题的题意就不说了,紫书上说的很详细了,关键是一点,什 ...

  9. 例题5-10 UVa207-PGA Tour Prize Money(WA)

    这道题真的是搞心态的神仙题了,由于到最后还是晕晕乎乎+WA,所以就不多说了,直接贴代码. 题目链接:UVa 207 WA代码: #include <iostream> #include & ...

最新文章

  1. Python爬虫入门教程 57-100 python爬虫高级技术之验证码篇3-滑动验证码识别技术
  2. php异常处理方式,PHP异常处理办法
  3. MySQL中函数CONCAT及GROUP_CONCAT
  4. centos 上docker 运行出现/bin/sh: . not found
  5. 【JSON】数据格式
  6. Java Learning Path(四) 方法篇
  7. Java程序设计基础--流程控制
  8. C++ 操作64位系统,默认读取Wow6432Node子键的解决方法。
  9. C#知识点总结系列:C# 数据结构
  10. 高一学生计算机知识现状分析,关于高中信息技术课教学现状的思考
  11. java utf8转iso8859-1_Java字符编码处理(UTF-8/ISO-8859-1)之一 –读文本文件乱码问题 | 学步园...
  12. vue 登录页面记住密码功能
  13. java md5加密源码_javaMD5加密源码
  14. 前端程序员必须要懂的 UI 设计知识
  15. Qt编写物联网管理平台32-表格数据
  16. 苹果cms用拼音伪静态之后,播放页密码访问失效解决方法
  17. tablayout如何设置字体大小,颜色等属性
  18. rasa x The path ‘config.yml‘ does not exist. Please make sure to use the default location
  19. CAD图案进行快速填充以及创建边界应该怎么实现?
  20. IntelliJ IDEA 设置对象图片及改变透明度

热门文章

  1. 主题模型结合词向量模型(Improving Topic Models with Latent Feature Word Representations)
  2. Ubuntu 18.04 vscode 编辑器空格显示过小问题解决方案
  3. 【trick 5】warmup —— 一种学习率调优方法
  4. 在ARM板子上把玩Tensorflow Lite
  5. oracle中文名转拼音,oracle 汉字转拼音
  6. 使用Springboot实现Nginx均衡负载功能
  7. 使用CStdioFile操作文件
  8. Adaboost入门教程——最通俗易懂的原理介绍(图文实例)
  9. 电梯控制算法(5)单电梯场景——屏蔽较近楼层进梯请求
  10. Scrapy第十五篇:后起之秀-Playwright