Under construction

Still being built. Things may change

Contest

Time limit1sMemory limit1024 MB

Summary
Parse a contest log in time order and compute each participant's total score using the per-problem formula with wrong-answer penalties.
Level

Easy3 of 10

Topics
Simulation, Implementation, Array, Math
Solved
No attempts yet

Problem

Programming contests come in many forms. There are contests where you compete against people around the world, such as the Informatics Olympiad, ACM-ICPC, and ICFP, and there are domestic contests such as the Supercomputing Contest, Pasocon Koshien, and EPOCH @Matsuyama. The list goes on.

Participating in such contests makes some people want to hold one of their own. Your friend is one of them. Your friend is busy preparing contest problems and has asked you to write a program that computes participant scores from the contest log. Write a correct scoring program so that your friend's contest succeeds.

The contest has N participants, M problems, and a contest duration of T seconds. Participants are assigned numbers from 1 to N. Problems are also assigned numbers from 1 to M.

In this contest, for each problem, each participant reads the statement, solves the problem, and submits the source code of a solution. The contest starts at time 0 and ends at time T. When a participant reads a problem, the time, participant number, and problem number are recorded as one entry in the log. When a participant submits source code, the time, participant number, problem number, and whether the submitted source code is correct are recorded as one entry in the log.

Each participant may, once every second from the start of the contest, do exactly one of the following: read a problem, or submit the source code of a problem. It is not possible to submit source code for a problem before reading it, or to submit source code again after solving it correctly.

When participant j reads problem i at time Sij, submits wij incorrect source codes, and then submits a correct source code at time Eij, the score is

the larger of (pi − (Eij − Sij) − 120wij) and X

where pi is the point value of problem i, and X is the minimum score for a correct solution that does not depend on the problem number.

A problem not solved correctly by the end of the contest scores 0 points.

The score of each participant is the sum of that participant's scores over all problems.

Given N, M, T, X, the number of entries in the log, the point value of each problem, and the contents of the log, write a program to compute the score of each participant.

Input

Read the following input from standard input.

  • The first line contains the number of participants N, the number of problems M, the contest duration T, the minimum score for a correct problem X, and the number of log entries Y, separated by spaces.
  • Of the following M lines, the i-th line contains the integer pi, the score of problem i.
  • The following Y lines describe the log. Of these, the k-th line contains the integer tk, the time the k-th entry was recorded, the integer nk, the participant number, the integer mk, the problem number, and one of the strings "open", "correct", or "incorrect", separated by spaces. "open" means the problem was read. "correct" means the submitted source code was correct. "incorrect" means the submitted source code was incorrect.

Output

Write the following data to standard output.

  • The data consists of N lines, and the j-th line contains the score of participant j.

Constraints

  • 1 ≤ N ≤ 1,000 number of participants
  • 1 ≤ M ≤ 10 number of problems
  • 100 ≤ T ≤ 10,000 contest duration
  • 1 ≤ X ≤ 100 minimum score for a correct problem
  • 0 ≤ Y ≤ 10,000 number of log entries
  • X ≤ pi ≤ T score of problem i
  • 0 ≤ t1 ≤ t2 ≤ . . . ≤ tk ≤ . . . ≤ tY ≤ T integer representing the time the k-th log entry was recorded
  • 1 ≤ nk ≤ N participant number in the k-th log entry
  • 1 ≤ mk ≤ M problem number in the k-th log entry

Examples2

  1. Example 1

    Input
    1 3 1200 30 8
    50
    1000
    800
    0 1 1 open
    100 1 2 open
    400 1 1 correct
    500 1 2 incorrect
    600 1 2 correct
    700 1 3 open
    800 1 3 incorrect
    900 1 3 incorrect
    
    Expected output
    410
    
  2. Example 2

    Input
    3 2 1000 10 10
    878
    712
    0 2 1 open
    0 1 1 open
    0 3 1 open
    100 3 1 correct
    100 2 1 correct
    100 1 2 open
    200 2 2 open
    200 1 2 incorrect
    300 1 2 correct
    300 2 2 correct
    
    Expected output
    392
    1390
    778