书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

数组的强大作用

 

Description

As a contestant, you must be familiar with the rules of ACM-ICPC. Teams are ranked according to the most problems solved. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the accepted run plus 20 penalty minutes for every rejected run for that problem regardless of submittal time. There is no time consumed for a problem that is not solved. Teams who solve the same number of problems and the same total time are ranked by their names in alphabetical order. 

Any submit of a problem by those teams who has solved this problem before would be ignored!

Caspar (a coach of SCPC) wants to know when the rank of his students’ team changed. He makes a curve to show the rank’s changes of his students’ team. Now, give you the information of every submission. Your problem is to calculate the changing points of a giving team. 



Input

 

There is ONLY ONE TESTCASE.

The first line is an integer N (1<=N<=200) which indicates the number of submissions, and the number of teams is less than 20.

Each of the following N lines has four operations A (indicating the Name of the team who submitted this code, no more than 20 characters), B(an integer indicating the submitted time), C (indicating the ID of problem, only one uppercase character), D (indicating the result of this run, ‘Y’ means accepted and ‘N’ means not accepted).

Then an integer M followed in one line.

Each of the following M lines has only one string indicating the team name which Caspar wants to check its curve.

We promise that there is at most one submit in the same time and each of those teams Caspar want to check has at least one submit in this competition.

 

Output

 

For each team that Caspar wants to check its curve. You should output the changing points of the team in several lines. Each line has two number T, R indicating the time when the rank has been changed and rank. You should output as this format “time:T rank:R”. There is a blank line followed.

After that, you should output the final rank of all teams.

 

Sample Input

16
TEAM1 1 A Y
TEAM2 2 A N
TEAM2 3 A Y
Dream 4 A Y
TEAM3 5 A Y
TEAM3 6 B Y
TEAM4 7 A Y
TEAM4 8 B Y
TEAM4 9 C Y
Dream 10 B Y
Dream 11 C Y
TEAM3 12 C Y
TEAM1 13 B Y
TEAM1 14 C Y
TEAM1 15 D Y
Dream 16 D Y
2
Dream
TEAM1

Sample Output

time:4 rank:2
time:6 rank:3
time:8 rank:4
time:10 rank:3
time:11 rank:2
time:12 rank:3
time:15 rank:4
time:16 rank:1

time:1 rank:1
time:6 rank:2
time:8 rank:3
time:10 rank:4
time:15 rank:1
time:16 rank:2

Dream
TEAM1
TEAM3
TEAM4
TEAM2

复制代码
#include "iostream"
#include "cstring"
#include "algorithm"
#include "string"
#include "map"
using namespace std;
#define sz 21
#define ca 201
int tm[sz][ca], rk[sz][ca], wg[sz][ca];
bool AC[sz][ca];
struct submit
{
string na;
int ti;
char pr, sb;
}s[ca];
struct team
{
string na;
int an, at, ra;
}t[sz], tt[sz];
bool check(team a, team b)
{
if(a.an > b.an) return true;
if(a.an==b.an && a.at<b.at) return true;
if(a.an==b.an && a.at==b.at && a.na<b.na) return true;
return false;
}
int main()
{
int n, k1 = 0, k2 = 0, flag1, flag2, df[sz], who, whi, nowtime;
string ne;
map<string, int> nm; //name
map<char, int> pm; //probelm
for(int i=0; i<21; i++)
{
t[i].an = 0; t[i].at = 0;
t[i].ra = 0; df[i] = 0;
}
memset(tm, 0, sizeof(tm)); memset(rk, 0, sizeof(rk));
memset(wg, 0, sizeof(wg)); memset(AC, false, sizeof(AC));
cin>>n;
for(int i=0; i<n; i++)
{
flag1=1; flag2=1;
cin>>s[i].na>>s[i].ti>>s[i].pr>>s[i].sb;
nowtime = s[i].ti;
for(int j=0; j<i; j++)
{
if(s[i].na==s[j].na) flag1=0;
if(s[i].pr==s[j].pr) flag2=0;
}
if(flag1)
{
t[k1].na = s[i].na; //存入姓名
nm[s[i].na]=k1; k1++;
}
if(flag2)
{
pm[s[i].pr]=k2;
k2++;
}
who = nm[s[i].na]; whi = pm[s[i].pr];
if(s[i].sb=='N') wg[who][whi]++;
else if(AC[who][whi]==false)
{
AC[who][whi]=true;
t[who].an++;
t[who].at+=(nowtime+20*wg[who][whi]);
}
for(int i=0; i<k1; i++) tt[i] = t[i];
sort(tt, tt+k1, check);
for(int j=0; j<k1; j++)
{
who = nm[tt[j].na];
if(t[who].ra!=(j+1)) //j+1是现在的排名
{
t[who].ra = j+1; df[who]++;
tm[who][df[who]]=nowtime; //记录提交时的时间
rk[who][df[who]]=j+1;
}
}
}
cin>>n;
while(n--)
{
cin>>ne;
for(int i=1; i<=df[nm[ne]]; i++) cout<<"time:"<<tm[nm[ne]][i]<<" rank:"<<rk[nm[ne]][i]<<endl;
cout<<endl;
}
for(int i=0; i<k1; i++) cout<<tt[i].na<<endl;
return 0;
}
复制代码


posted on   More study needed.  阅读(421)  评论(0编辑  收藏  举报

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
< 2011年11月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示