上面都是废话
For each submission, if it is the first time that the judge returns ``AC'' on this problem, then it means you have passed this problem, and the current time will be added to the penalty of your team. In addition, every time you pass a problem, each unsuccessful try for that problem before is counted as 20 minutes penalty, it should also be added to the penalty of your team.
Now given the number of problems in the contest and the submission records of a team. Please write a program to calculate the number of problems the team passed and their penalty.
Input
The first line of the input contains an integer T(1≤T≤20), denoting the number of test cases.
In each test case, there are two integers n(1≤n≤13) and m(1≤m≤100) in the first line, denoting the number of problems and the number of submissions of a team. Problems are labeled by 1001, 1002, ..., 1000+n.
In the following m lines, each line contains an integer x(1001≤x≤1000+n) and two strings t(00:00≤t≤05:00) and s, denoting the team submits problem xat time t, and the result is s. t is in the format of HH:MM, while s is in the set \{AC, PE, WA, RE, TLE, MLE, OLE\}. The team is so cautious that they never submit a CE code. It is guaranteed that all the t in the input is in ascending order and every t is unique.
Output
For each test case, print a single line containing two integers A and B, denoting the number of problems the team passed and the penalty.
题意:按照ACM规则计算过题数和罚时,注意第一次AC了某道题后,这道题再交就没任何影响了
一开始拿mp[x]=-1表示已经AC,但是没有卡主else循环,导致wa了两发。想起LRJ说过拿数去做标记有时候就是会出现这种易错的情况,反正也不缺那点空间,以后还是开数组标记叭
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int T;
map<int,int> mp;
int penalty(string t)
{
int i=0;
int h=0,m=0;
h=(t[0]-'0')*10+(t[1]-'0');
m=(t[3]-'0')*10+(t[4]-'0');
return h*60+m;
}
int main()
{
cin>>T;
while(T--)
{
int n,m;
cin>>n>>m;
mp.clear();
int ans=0;
int cnt=0;
for(int i=1;i<=m;++i)
{
int x;
string t,s;
cin>>x>>t>>s;
if(s[0]=='A'&&mp[x]!=-1) //保证A了的题只算一次
{
cnt++;
ans+=penalty(t);
ans+=mp[x]*20;
mp[x]=-1;
}
else //最好用vis,这里一开始没发现wa了两发
{
if(mp[x]==-1) continue;
mp[x]++;
}
}
cout<<cnt<<' '<<ans<<endl;
}
return 0;
}