当前位置: 代码迷 >> 综合 >> TZOJ 2748: TOJ Contest
  详细解决方案

TZOJ 2748: TOJ Contest

热度:99   发布时间:2023-12-16 15:45:47.0

描述

Hi, welcome to the 3rd Taizhou University Programming Contest and best regards to you! To avoid bringing you any troubles, you should know our system how to judge your contest score after you submit your code. Your task in this problem is to compute the score for a number of submissions from a programming contest contestant.

输入

Each line of input contains a problem identifier (a single letter from A to Z), a time (in minutes from 0 to 300), and a judgement (the word “correct” or the word “incorrect”). The input is in ascending order by time, and there will be at most one “correct” judgement for each problem. A line containing ‘-’ follows the last line of input.

输出

The output has two components: solved and penalty. solved is the number of distinct problems with a “correct” judgement. penalty is the sum of the time at which each distinct problem is first judged “correct”, and 20 for each “incorrect” submission for a problem that is later judged “correct”.

样例输入

A 100 correct
B 110 incorrect
B 111 correct
C 200 correct
D 233 incorrect

样例输出

3 431

解题思路

只要判断一道题最后有没有解出来就好了,并且标记每道题错误的次数。

代码

#include <bits/stdc++.h>
using namespace std;
map<string,int>map1;
struct node
{
    string str;string a;int t;
};
node m;
int main()
{
    int sum=0,cnt=0;while(cin>>m.a,m.a!="-"){
    cin>>m.t>>m.str;if(m.str=="correct"){
    sum=sum+map1[m.a]*20+m.t;cnt++;}else if(m.str=="incorrect"){
    map1[m.a]++;}}printf("%d %d\n",cnt,sum);return 0;
}
  相关解决方案