真心是道水题,但找bug找的我想剁手了/(ㄒoㄒ)/~~

注意几个坑点,

1、输入,getline(cin); / gets(); 一行输入,注意前面要加getchar();

   输入运行记录的时候可以采取scanf("%d %c %d %c");的方式,因为已经说一个整型数后面只有一个空格;

2、该场没人出题时,队伍的得分是0;

某支队伍j比0场时,T[j] = 0;

3、如果前两支队伍出题数与罚时都相同,排名并列第1;后面的队伍从3开始排;

基本上没有了吧...被恶心到了。本应该出的题又被自己的粗心祸害了。这次比的仍是很糟,希望尽快好起来。。。

 #include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = b; i >= a; i--)
#define sfi(n) scanf("%d", &n)
#define sfl(n) scanf("%I64d", &n)
#define pfi(n) printf("%d\n", n)
#define pfl(n) printf("%I64d\n", n)
#define MAXN 105
const int maxn = ;
const int maxm = ;
string Name[maxn]; struct TEAM
{
int id;
int Time;
int pro;
TEAM(int _x = , int _pro = , int _t = ):id(_x), pro(_pro), Time(_t) {}
bool operator < (const TEAM& rhs) const
{
if(rhs.pro != pro) return rhs.pro < pro;
else return Time < rhs.Time;
}
};
struct Score
{
int id;
double s;
Score(int _x = , double _s = 0.0) : id(_x), s(_s) {}
bool operator < (const Score& rhs) const
{
return rhs.s < s;
}
}; int C[maxn]; //i队参加比赛的次数
double S[maxn];
double RS[maxn];
double T[maxn];
int wa[maxn][]; //i队j题的WA次数 int main()
{
int Kase;
scanf("%d", &Kase);
for(int kk = ; kk <= Kase; kk++)
{
memset(C, , sizeof(C));
memset(S, , sizeof(S));
memset(RS, , sizeof(RS));
memset(T, , sizeof(T)); int n; scanf("%d", &n);
getchar();
int maxl = ;
for(int i = ; i <= n; i++)
{
getline(cin, Name[i]);
int len = Name[i].length();
maxl = max(maxl, len);
}
int m; scanf("%d", &m); for(int i = ; i <= m; i++)
{
int P[maxn]; //i队解决的问题数
int Time[maxn]; //i队罚时
int K; scanf("%d", &K); //第i场参加队伍数
int A = *K-, B = K-;
vector<int> team;
for(int j = ; j < K; j++)
{
int t;
scanf("%d", &t); team.push_back(t);
C[t]++;
}
int pn; scanf("%d", &pn);
int in; scanf("%d", &in);
memset(wa, , sizeof(wa));
while(in--)
{
int tt, tit;
char pt, flag;
scanf("%d %c %d %c", &tt, &pt, &tit, &flag);
if(flag == '+')
{
if(wa[tt][pt-'A'] != -)
{
Time[tt] += (tit+(wa[tt][pt-'A']*));
P[tt]++;
wa[tt][pt-'A'] = -;
}
}
else
{
if(wa[tt][pt-'A'] != -)
wa[tt][pt-'A']++;
}
} int PM = ; //A题最多数
vector<TEAM> team_;
for(int j = ; j < K; j++)
{
int tj = team[j];
team_.push_back(TEAM(tj, P[tj], Time[tj]));
PM = max(PM, P[tj]);
}
sort(team_.begin(), team_.end());
int R; //排名
for(int j = ; j < K; j++)
{
int tj = team_[j].id;
if(j && team_[j].pro == team_[j-].pro && team_[j].Time == team_[j-].Time) ;
else R = j+;
if(PM != )
RS[tj] = (1.0*P[tj])/PM;
else
RS[tj] = 0.0;
S[tj] += (RS[tj]*A)/(R+B); //tj队累计得分
}
}
vector<Score> ans;
for(int j = ; j <= n; j++)
{
if(C[j] == ) T[j] = 0.0;
else T[j] = S[j]/C[j]; //第j队总得分
ans.push_back(Score(j, T[j]));
}
sort(ans.begin(), ans.end()); //总得分排序,输出
for(int i = ; i < ans.size(); i++)
{
cout << Name[ans[i].id];
for(int j = ; j < (maxl+)-Name[ans[i].id].length(); j++)
{
printf(" ");
}
printf("%.4lf\n", ans[i].s);
}
if(kk != Kase) printf("\n");
}
return ;
}

【模拟ACM排名】ZOJ-2593 Ranking (Andrew Stankevich’s Contest #5)的更多相关文章

  1. [Andrew Stankevich's Contest#21] Lempel-Ziv Compression

    Time Limit: 20000/10000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)     Special Judge ...

  2. Andrew Stankevich's Contest (21) J dp+组合数

    坑爹的,,组合数模板,,, 6132 njczy2010 1412 Accepted 5572 MS 50620 KB C++ 1844 B 2014-10-02 21:41:15 J - 2-3 T ...

  3. Andrew Stankevich&#39;s Contest (1)

    Andrew Stankevich's Contest (1) 打一半出门了,回来才补完了...各种大数又不能上java..也是蛋疼无比 A:依据置换循环节非常easy得出要gcd(x, n) = 1 ...

  4. acdream:Andrew Stankevich Contest 3:Two Cylinders:数值积分

    Two Cylinders Special JudgeTime Limit: 10000/5000MS (Java/Others)Memory Limit: 128000/64000KB (Java/ ...

  5. 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest

    2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...

  6. ACM题目————zoj问题

    题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:20322 解决:3560 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. ...

  7. 拓扑排序--P2881 [USACO07MAR]排名的牛Ranking the Cows

    *传送 FJ想按照奶牛产奶的能力给她们排序.现在已知有N头奶牛(1 ≤ N ≤ 1,000).FJ通过比较,已经知道了M(1 ≤ M ≤ 10,000)对相对关系.每一对关系表示为“X Y”,意指X的 ...

  8. Linux下使用USB模拟ACM串口设备

    这个想法之前就在脑袋里有过,最近公司产品要用到,所以多做了些了解. 1. USB 简介 USB 是 Universal Serial Bus 的缩写,从字面上看,就是通用串行总线的意思.从物理上看,其 ...

  9. [ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]

    Description Have you played Draw Something? It's currently one of the hottest social drawing games o ...

随机推荐

  1. Cognos 增加全局类

    Cognos使用版本10.1.1 由于我服务器装的是linux系统下的,所以window系统下的方法,提一下,但是没有实现过. 1.Linux系统下增加全局类 ●修改GlobalReportStyle ...

  2. Spring MVC MultiActionController example

    In Spring MVC application, MultiActionController is used to group related actions into a single cont ...

  3. 转载Agile Development 敏捷软件开发介绍

    转载原地址: http://blog.csdn.net/wayne_ran/article/details/1601008 敏捷开发(agile development)是一种以人为核心.迭代.循序渐 ...

  4. python求3的倍数与和

    suqares=[] i=1 sum=0 while i<=100: i+=1 if i*3: sum=sum+i # print(i) suqares.append(i*3) # print( ...

  5. MySQL 5.5 手册下载

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  6. 解决 DCEF3 在 BeforePopup 事件中打开新窗体的问题

    此问题的解决方案从 https://groups.google.com/forum/#!topic/delphichromiumembedded/xzshOr-pjnU 获得. procedure T ...

  7. mysql中查询"_"这种特殊字符

    http://www.w3school.com.cn/sql/sql_wildcards.asp SQL 通配符 在搜索数据库中的数据时,SQL 通配符可以替代一个或多个字符. SQL 通配符必须与 ...

  8. ubuntu 15.04开放mysql远程连接

    首先查看端口是否打开 netstat -an|grep 3306 此图为开启3306端口的截图,之前显示为. . . 127.0.0.1:3306 . . . 打开mysql配置文件vi /etc/m ...

  9. IOS Note - Outlet(插座) & Action(动作)

    OutletActionViewController.h #import <UIKit/UIKit.h> @interface OutletActionViewController : U ...

  10. HDU 5522 Numbers 暴力

    Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5522 ...