【模拟ACM排名】ZOJ-2593 Ranking (Andrew Stankevich’s Contest #5)
真心是道水题,但找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)的更多相关文章
- [Andrew Stankevich's Contest#21] Lempel-Ziv Compression
Time Limit: 20000/10000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Special Judge ...
- 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 ...
- Andrew Stankevich's Contest (1)
Andrew Stankevich's Contest (1) 打一半出门了,回来才补完了...各种大数又不能上java..也是蛋疼无比 A:依据置换循环节非常easy得出要gcd(x, n) = 1 ...
- acdream:Andrew Stankevich Contest 3:Two Cylinders:数值积分
Two Cylinders Special JudgeTime Limit: 10000/5000MS (Java/Others)Memory Limit: 128000/64000KB (Java/ ...
- 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\)个白箱,将这 ...
- ACM题目————zoj问题
题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:20322 解决:3560 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. ...
- 拓扑排序--P2881 [USACO07MAR]排名的牛Ranking the Cows
*传送 FJ想按照奶牛产奶的能力给她们排序.现在已知有N头奶牛(1 ≤ N ≤ 1,000).FJ通过比较,已经知道了M(1 ≤ M ≤ 10,000)对相对关系.每一对关系表示为“X Y”,意指X的 ...
- Linux下使用USB模拟ACM串口设备
这个想法之前就在脑袋里有过,最近公司产品要用到,所以多做了些了解. 1. USB 简介 USB 是 Universal Serial Bus 的缩写,从字面上看,就是通用串行总线的意思.从物理上看,其 ...
- [ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]
Description Have you played Draw Something? It's currently one of the hottest social drawing games o ...
随机推荐
- (转载)JDOM/XPATH编程指南
JDOM/XPATH编程指南 本文分别介绍了 JDOM 和 XPATH,以及结合两者进行 XML 编程带来的好处. 前言 XML是一种优秀的数据打包和数据交换的形式,在当今XML大行于天下,如果没有听 ...
- Codeforces 599C Day at the Beach(想法题,排序)
C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunate ...
- linux 查看当前所在目录的全路径
有时候,使用linux的shell的时候需要查看当前位置的全路径,可以使用 pwd命令 当然,知道了该命令就可以通过man pwd来查看该命令的全部帮助手册.
- 不能发现 class "com.uustudio.unote.android.BaseApplication"
12-13 15:45:46.289: E/AndroidRuntime(3474): java.lang.RuntimeException: Unable to instantiate applic ...
- ASP导出Word带页眉页脚,中文不乱码
关键代码: <% Response.Clear() Response.CodePage= Response.Charset="UTF-8" Response.ContentT ...
- CSS 的 appearance 属性
在 Firefox 1.0+,Chrome 1.0+ 和 Safari 3.0+ 中,我们可以使用 -moz-appearance 或者 -webkit-appearance 属性让元素模仿系统原生控 ...
- C# winform 最小化到电脑右下角
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- mysql CASE WHEN的基础和多种用法
CASE计算条件列表并返回多个可能结果表达式之一. CASE 具有两种格式: 简单 CASE 函数将某个表达式与一组简单表达式进行比较以确定结果. CASE 搜索函数计算一组布尔表达式以确定结果. 两 ...
- 【不积跬步,无以致千里】AMQP协议介绍
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- CustomerSOList
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...