[POJ] 2379 -> ACM Rank Table
来源:互联网 发布:淘宝直通车优化软件 编辑:程序博客网 时间:2024/05/19 18:12
ACM Rank Table
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4523 Accepted: 1188
Description
ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:
Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.
- Each run is either accepted or rejected.
- The problem is considered solved by the team, if one of the runs submitted for it is accepted.
- The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submission of the first accepted run for this problem (in minutes) plus 20 minutes for every other run for this problem before the accepted one. For an unsolved problem consumed time is not computed.
- The total time is the sum of the time consumed for each problem solved.
- Teams are ranked according to the number of solved problems. Teams that solve the same number of problems are ranked by the least total time.
- While the time shown is in minutes, the actual time is measured to the precision of 1 second, and the the seconds are taken into account when ranking teams.
- Teams with equal rank according to the above rules must be sorted by increasing team number.
Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.
Input
Input contains integer numbers C N, followed by N quartets of integes ci pi ti ri, where ci -- team number, pi -- problem number, ti -- submission time in seconds, ri -- 1, if the run was accepted, 0 otherwise.
1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.
1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.
Output
Output must contain C integers -- team numbers sorted by rank.
Sample Input
3 31 2 3000 01 2 3100 12 1 4200 1
Sample Output
2 1 3
解题思路:
可能出现以下几个问题:
1.ac了的题目重复提交
2.有可能不按时间顺序排列
3.没k题过的队伍也要算上
4.提交时间和罚时单位一个是秒一个是分钟
Code:
#include <iostream>#include <vector>#include <algorithm>using namespace std;typedef struct Team{int ci;int count;int time;int wrong[21];Team() : count(0), time(0) { memset(wrong, 0, 21 * sizeof(int)); }} Team;typedef struct Submission{int ci, pi, ti;bool ri;Submission(int c, int p, int t, bool r) : ci(c), pi(p), ti(t), ri(r) {}}Submission;bool cmp_subs(Submission& sub1, Submission sub2){return sub1.ti < sub2.ti;}bool cmp_teams(Team& t1, Team& t2){if (t1.count != t2.count)return t1.count > t2.count;else if (t1.time != t2.time)return t1.time < t2.time;else return t1.ci < t2.ci;}int main(){int C, N, ci, pi, ti;bool ri;cin >> C >> N;Team* teams = new Team[C+1];vector<Submission> subs;for (int i = 1; i <= C + 1; ++i)teams[i].ci = i;for (int i = 0; i < N; i++){cin >> ci >> pi >> ti >> ri;Submission sub(ci, pi, ti, ri);subs.push_back(sub);}sort(subs.begin(), subs.end(), cmp_subs);for (vector<Submission>::iterator it = subs.begin(); it != subs.end(); ++it){if (teams[it->ci].wrong[it->pi] != -1) { //如果没有提交(有些白痴队伍ac了还要重复提交)if (it->ri == true){teams[it->ci].time += teams[it->ci].wrong[it->pi] * 20 * 60 + it->ti;++teams[it->ci].count;teams[it->ci].wrong[it->pi] = -1;} else ++teams[it->ci].wrong[it->pi];}}sort(teams + 1, teams + C + 1, cmp_teams);for (int i = 1; i < C; i++)cout<<teams[i].ci<<" ";cout << teams[C].ci << endl;return 0;}
0 0
- poj 2379 ACM Rank Table
- poj 2379 ACM Rank Table
- [POJ] 2379 -> ACM Rank Table
- poj 2379 ACM Rank Table
- ACM Rank Table POJ
- POJ 2379 ACM Rank Table(水~)
- ACM Rank Table(poj 2397)
- POj 2379 ACM Rank Table
- ACM Rank Table
- (STL自带的排序功能7.1.3)POJ 2379 ACM Rank Table(结构体的排序、初始化)
- ACM-STEP Rank
- poj 2153 Rank List
- poj 2153 Rank List
- POJ 2153 Rank List
- poj 2153 Rank List
- Poj 2153 Rank List
- POJ 2135 Rank List
- hdu 5096 ACM Rank(treap)
- Web端服务器推送技术原理分析及dwr框架简单的使用
- 1009. 说反话
- 【Boost】boost库asio详解4——deadline_timer使用说明
- xcode APP 打包以及提交apple审核详细流程(新版本更新提交审核)
- oracle 备份还原
- [POJ] 2379 -> ACM Rank Table
- java反射机制
- 论java中面向对象与php区别
- 1010. 一元多项式求导
- 最牛脚本开发
- 算法和数据结构就是编程的一个重要部分,你若失掉了算法和数据结构,你就把一切都失掉了
- 聚合关系与组合关系
- 地址转换函数inet_aton、 inet_ntoa、 inet_addr和inet_pton 、inet_ntop
- 再析spring注解事务之事务传播