POJ 2379 ACM Rank Table(排序)
题很水,数据注意一下四点即可:
1.有些team会在一道题AC了之后还提交,这个时候只需要算第一次ac的时间以及这之前的wa,之后的全部忽略。
2.如果一道题没有ac,那么在计算时间时不应该加上它的wa带来的惩罚。
3.先按做题最多的排,如相等,再按提交时间最少的排,如相等,再按队号最小的排。
4.给的数据,提交的时间不是按顺序排的。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std;
const int maxn=;
int C,N;
int c,p,t,r;
int res[maxn][maxn]; //res[c][p]=1表示队伍c解决了第p题,=0则未AC。
//存储提交的信息
struct Submit{
int team,pro,time,result; //队伍号,题号,提交时间,提交结果
void init(int c,int p,int t,int r){
team=c;
pro=p;
time=t;
result=r;
}
//按提交时间从小到大排序,如果时间一样,AC的排在前面
bool operator<(const Submit tmp)const{
if(time==tmp.time)
return result>tmp.result;
return time<tmp.time;
}
}sub[maxn];
//队伍信息
struct Team{
int time,idx,wa[],num; //总时间,队伍号,各题号WA的次数,AC的题数
void init(int i,int n,int t){
idx=i;
num=n;
time=t;
memset(wa,,sizeof(wa));
}
//按AC的题数从大到小排序,如果相同则按时间从小到大排序,如果时间也相同,队伍号小的在前面
bool operator<(const Team tmp)const{
if(num==tmp.num){
if(time==tmp.time)
return idx<tmp.idx;
else
return time<tmp.time;
}
return num>tmp.num;
}
}team[maxn];
int main()
{
memset(res,,sizeof(res)); scanf("%d%d",&C,&N);
for(int i=;i<=C;i++){
team[i].init(i,,);
}
for(int i=;i<N;i++){
scanf("%d%d%d%d",&c,&p,&t,&r);
sub[i].init(c,p,t,r);
}
sort(sub,sub+N);
for(int i=;i<N;i++){
c=sub[i].team;
p=sub[i].pro;
t=sub[i].time;
r=sub[i].result;
if(r== && !res[c][p]){
team[c].wa[p]++;
}
else{
if(!res[c][p]){
team[c].time+=t;
res[c][p]=;
team[c].num++;
}
}
}
for(int i=;i<=C;i++){
for(int j=;j<=;j++){
//题目AC了,才加上相应的罚时
if(res[i][j]){
team[i].time+=team[i].wa[j]**;
}
}
}
sort(team+,team+C+);
for(int i=;i<=C;i++){
if(i==)
printf("%d",team[i].idx);
else
printf(" %d",team[i].idx);
}
return ;
}
POJ 2379 ACM Rank Table(排序)的更多相关文章
- A - ACM Rank Table
ACM contests, like the one you are participating in, are hosted by the special software. That softwa ...
- POJ - 1245 Programmer, Rank Thyself
POJ - 1245 Programmer, Rank Thyself Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d ...
- Table排序
<html> <head> <title>tablesorter表单排序插件</title> <link type ="text/css ...
- lua table排序报错与解决
lua table排序 table的sort函数 比如按照大小进行排序,下面这种写法在某些情况下可能会排序错误,甚至报invalid order function for sorting table. ...
- POJ 3436 ACM Computer Factory (网络流,最大流)
POJ 3436 ACM Computer Factory (网络流,最大流) Description As you know, all the computers used for ACM cont ...
- javascript table排序之jquery.tablesorter.js
table排序 jquery.tablesorter.js 一.Demo下载地址: 1.tablesorter.js下载地址: http://download.csdn.net/detail/zhan ...
- Poj 3436 ACM Computer Factory (最大流)
题目链接: Poj 3436 ACM Computer Factory 题目描述: n个工厂,每个工厂能把电脑s态转化为d态,每个电脑有p个部件,问整个工厂系统在每个小时内最多能加工多少台电脑? 解题 ...
- js实现table排序(jQuery下的jquery.sortElements)
项目中要实现table排序的功能. 网上有非常多解决方式,非常多都基于jQuery. jquery.tablesorter.大小17KB.只是他的首页在ie10下兼容性有点问题. DataTables ...
- [ACM] POJ 3687 Labeling Balls (拓扑排序,反向生成端)
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10161 Accepted: 2810 D ...
随机推荐
- 济南学习 Day 1 T2 am
死亡[问题描述]现在有M个位置可以打 sif,有N +1个人在排队等着打 sif.现在告诉你 个人每个人需要多长的时间打 sif,问你第N +1个人什么时候才能打 sif. (前N个人必须按照顺序来) ...
- 利用word2vec对关键词进行聚类
1.收集预料 自己写个爬虫去收集网页上的数据. 使用别人提供好的数据http://www.sogou.com/labs/dl/ca.html 2.对预料进行去噪和分词 我们需要content其中的值, ...
- photoshop如何把阴影分离开(让阴影单独成为一个图层)
作图的时候经常会用到,给图片加个投影,但有时还满足不了自己的需要,于是可以把投影分离开来单独操作投影. 图层->图层样式->创建图层 有时还需要滤镜->模糊 一下 哈哈,下次忘了来翻 ...
- 更新win7资源管理器
更新exeplorer.exe: 1.方法1: void RefreshExplorer() { ]; SHELLEXECUTEINFOA shellExeInfo={}; shellExeInfo. ...
- jQuery插件使用大全
1.jQuery datepicker日历插件使用说明 http://wenku.baidu.com/view/12804e1e59eef8c75fbfb3e3 2.jqueryFileUpload插 ...
- 转:Apache与Nginx的优缺点比较
Apache与Nginx的优缺点比较 http://weilei0528.blog.163.com/blog/static/206807046201321810834431/ 1.nginx相对于ap ...
- DML,DDL,DCL,DQL的区别
DML 英文缩写 DML = Data Manipulation Language,数据操纵语言,命令使用户能够查询数据库以及操作已有数据库中的数据的计算机语言.具体是指是UPDATE更新.INS ...
- 虚拟局域网VLAN
6.5.1配置路由器广域网端口的PPP封装 (1)配置路由器A: Router>enable Router#config Router_config#hostname Router-A Rout ...
- 1095. Cars on Campus (30)
Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out time ...
- boost-内存管理
Boost智能指针——scoped_ptr boost::scoped_ptr和std::auto_ptr非常类似,是一个简单的智能指针,它能够保证在离开作用域后对象被自动释放. boost::sco ...