QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100

#22397. Time Cards

통계

Farmer John wanted to improve farm productivity, so his cows now get extra hay if they spend more time at a milking machine. To implement this plan, he has instituted the use of time cards for each of the $N$ ($1 \le N \le 145$) cows conveniently numbered $1..N$. When a cow starts at a milking machine, she enters the start time on the master time card. Likewise, when she leaves, she notes that on the master time card, as well. FJ is fortunate to have enough milking machines that he can milk every cow at the same time.

The time entries are typed into a computer file where each line includes a cow number $C$ ($1 \le C \le N$), a keyword ('START' or 'STOP'), and the time expressed as two space-separated integers $HH$ and $MM$ ($0 \le HH \le 23$; $0 \le MM \le 59$). Cows never stay at the machine past midnight. The timecard file is complete in the sense that every cow's START entry contains a corresponding STOP entry later in the input file.

Calculate the total time each cow spends at the milking machine.

By way of example, consider a time card file for just two cows. The file includes not only the number of cows but also the total number of time card entries, $Nlines$ ($1 \le Nlines \le 1,458$).

2 6
1 START 9 0
2 START 9 30
1 STOP 10 0
2 STOP 10 15
1 START 17 0
1 STOP 17 42

Cow 1 spent times 9:00-10:00 and 17:00-17:42 at the machine for a total of one hour and 42 minutes (1:42). Cow 2 spent time 9:30-10:15 at the machine, for a total of 45 minutes.

Input

  • Line 1: Two space-separated integers: $N$ and $Nlines$
  • Lines $2..Nlines+1$: Each line contains four space-separated entities: $C$, keyword, $HH$, and $MM$

Output

  • Lines $1..N$: Line $i$ contains two space-separated integers that are respectively the number of hours and minutes that cow $i$ spends at the milking machine. Of course, the minutes value never exceeds 59.

Examples

Input 1

2 6
1 START 9 0
2 START 9 30
1 STOP 10 0
2 STOP 10 15
1 START 17 0
1 STOP 17 42

Output 1

1 42
0 45

Problem credits: Rob Kolstad, 2009

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.