真心是道水题,但找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. vim MiniBufExplorer 插件

    MiniBufExplorer安装好久了,但一直没怎么使用过. 今天查了下资料,作为一个备份. 当你只编辑一个buffer的时候MiniBufExplorer派不上用场, 当 你打开第二个buffer ...

  2. ubuntu 备份安装程序列表

    一般情况下,我们重装ubuntu的系统会做如下几个事情 1)修改默认的程序更新源 2)开始根据需求安装软件. 3)配置文件(如vim/tmux等) 对于步骤,只需要cp /etc//etc/apt/s ...

  3. ISP与IAP的区别

    转: ISP(In-System Programming)在系统可编程,指电路板上的空白器件可以编程写入最终用户代码, 而不需要从电路板上取下器件,已经编程的器件也可以用ISP方式擦除或再编程.IAP ...

  4. Redis安装与调试

    Redis安装与调试 Redis安装与调试linux版本:64位CentOS 6.5 Redis版本:2.8.17  (更新到2014年10月31日) Redis官网:http://redis.io/ ...

  5. 面试之BI-SQL--table转换

    题目如下: Num 1 2 4 6 7 8 10 11 13 写条SQL语句转成下表: Column1  Column2 1              2 4              4 6     ...

  6. HDU 1255 覆盖的面积 (线段树+扫描线+离散化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1255 题意很清楚,就是让你求矩阵之间叠加层数大于1的矩形块的面积和. 因为n只有1000,所以我离散化 ...

  7. oracle 11g 之 result cache

    oracle 11g 之 result cache 今天是2013-10-12,打算最近时间研究一下shared pool的相关原理以及awr报告分析.今天学习一下在oracle 11g shared ...

  8. Random的nextInt用法

    因为想当然的认为Random类中nextInt()(注:不带参数),会产生伪随机的正整数,采用如下的方式生成0~99之间的随机数: Random random = new Random(); rand ...

  9. Unity3D之飞机游戏追踪导弹制作

    最近开发完成一款打飞机的游戏,记录一下制作追踪导弹的方法,最开始在网上找到的资料制作出来的追踪导弹都不够真实,主要的问题是没有对导弹进行一个阀值处理,导弹每帧都始终会面向目标,而不是按照一定的角度进行 ...

  10. MyGeneration模板生成NHibernate映射文件和关系(one-to-one,one-to-many,many-to-many)

    MyGeneration的几个NHibernate模板功能已经很强,但还是存在些问题.例如:Guid主键支持不佳,代码不易修改,不支持中文注释等等.所以我决定自己来改写此模版.我把一部分通用的函数提取 ...