eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Hey, Pay Day!

Hey, Pay Day!

An automatic machine is used in a factory for controlling entrance and exit of workers. Each worker has an electronic identification (\textbf{ID}) card that has to be inserted into the machine every time the worker enters or leaves the factory. The machine reads the name (say \textbf{S}) from the \textbf{ID} card, and the current date (say, \textbf{D}) and time (say, \textbf{T}) from its internal timer, and generates a new record, denoted by \textbf{D--S--T}, in its database. The entrance time is no sooner than \textbf{8:00:00}, and the exit time is no later than \textbf{20:00:00}. The factory also has a watchman who is always present and carefully records the entrances and exits of all workers and of the clients. He creates a separate list each day that contains the names of the people (workers or clients) who enter or exit the factory during that day. The list is in the same order as the people enter or exit. The names of workers on this list are exactly the same strings as recorded by the automatic machine. Note that clients do not have \textbf{ID} cards. It is quite possible that some workers forget to insert their \textbf{ID} cards into the machine. But, we assume that each worker makes this mistake at most once each day. We also know that each worker that comes to work in the factory on a certain day, enters the factory exactly once and leaves it exactly once on that day. At the end of the month, and on the pay day, the director of the factory notes that, with the information recorded by the automatic machine and the lists prepared by the watchman, it is not possible to find out exactly how many hours each worker has been present (working) in the factory in the past month. He, therefore, decides to pay each worker \textbf{100}K Rials multiplied by the "\textbf{average}" time he/she has been present in the factory during these days. The "\textbf{average}" time is computed as the average of two numbers: one is the minimum possible and the other is the maximum possible time the worker has been present in the factory during the working days in the past month. You are to write a program to find out the minimum and the maximum possible time each worker has been present in the factory. \InputFile In the first line of input, there is an integer \textbf{t} (\textbf{1} ≤ \textbf{t} ≤ \textbf{10}), the number of test cases, followed by the data for the test cases. Each line of a test case is a record of machine database or reports of watchman at the end of a day. Each line representing a machine record is like \textbf{D--S--T}, where \textbf{S} is a string of lower case letters, \textbf{D} is a date, formatted like \textbf{YY/MM/DD}, and \textbf{T} is a time stamp, formatted like \textbf{HH:MM:SS}. There is no blank character in this kind of input lines. Each line representing a watchman's report of a single day containing \textbf{1} ≤ \textbf{k} ≤ \textbf{40} names like the following: \textbf{D S_1 S_2 S_3 … S_k} Which means that at date \textbf{D} (with format \textbf{YY/MM/DD}), first person named \textbf{S_1} entered or left the factory, then the second person named \textbf{S_2}, and so on. The date and the names are separated by one blank character. In a test case, there cannot be more than one line of kind watchman’s report for the same date. The period of interest is no more than \textbf{30} days. Person names are not more than \textbf{15} characters and no two persons have the same name. Each test case terminates with a line containing a single \textbf{#} character. The company has at least one employee and at most \textbf{15 }employees. Two machine records of a certain date may have the same time stamp. In this case, the watchman may record the corresponding events in any order. \OutputFile The output file contains answers to the test cases with the \textbf{i}^th answer corresponding to the \textbf{i}^th test case. Each line of an answer is of the form: \textbf{S-H_1 M_\{1 \} S_1-H_\{2 \} M_\{2 \} S_2} Where \textbf{S} is the name of a worker, \textbf{H_1}, \textbf{M}_\{1 \}and_\{ \}\textbf{S}_\{1 \}represent the minimum presence time of the worker \textbf{S} during period of interest, and \textbf{H_2}, \textbf{M}_\{2 \}and_\{ \}\textbf{S}_\{2 \}represent the same for maximum presence time of the worker \textbf{S}. (\textbf{H_i}, \textbf{M_i}, and \textbf{S_i} specify hours, minutes and seconds without any leading zeros.) The lines in each answer should be sorted on field \textbf{S} alphabetically (dictionary sort). Each answer terminates with a line containing a single \textbf{#} character.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2
99/10/03-sarah-09:00:00
99/10/03-sarah-14:00:00
99/10/04-ali-17:00:00
99/10/03-maryam-09:02:00
99/10/03-ali-10:20:15
99/10/04 ali reza sarah hamid ali reza sarah hamid
99/10/03-ali-12:00:00
99/10/03-maryam-09:04:00
99/10/04-sarah-18:00:00
99/10/03 sarah maryam maryam hamid hamid ali hassan ali sarah hassan
99/10/04-ali-13:00:00
#
99/10/03-sarah-09:00:00
99/10/03-sarah-14:00:00
99/10/04-ali-17:00:00
99/10/03-ali-10:20:15
99/10/04 ali sarah ali sarah
99/10/03-ali-12:00:00
99/10/04-sarah-18:00:00
99/10/03 sarah ali ali sarah
99/10/04-ali-13:00:00
#
Выходные данные #1
ali-5 39 45-5 39 45
maryam-0 2 0-0 2 0
sarah-6 0 0-10 0 0
#
ali-5 39 45-5 39 45
sarah-6 0 0-10 0 0
#