- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
You are assigned to write a software for a medical laboratory. A portion of the software is about generating reports on the conducted medical tests. A medical test consists of a series of measurements on specimens (like blood or urine) sampled from a patient. Each measurement has a name, a unit, and a result (value). For example, the “Cholesterol” in a blood sample might be $180 mg$/$dl$. Additionally, each measurement is attached with a reference table. A reference table is a general set of rules classifying a (status) flag for the patients based on their measurement results. For example, if “Triglycerides” has a result in the range $[10,190]$, then it is classified as “normal”; and it is flagged as “low” or “high” if it has a result below or above this range, respectively.
Given all the measurement reference tables and the results for several patients, you have to generate the report of their medical tests.
ورودی
A text in the input specification of this problem is a non-empty string of arbitrary printable ASCII characters, including the space, punctuation, and alphanumeric characters, but not the newline character. It is guaranteed that a text does not start or end with the white space characters. In addition, all real numbers in the input are in decimal format with at most $7$ characters, and their absolute value will not exceed $10^7$.
The input consists of multiple (at least $2$ and at most $100$) sections. Each section ends with a single line containing $80$ consecutive =
characters.
The reference tables are described in the first section. There are at least $1$ and at most $100$ reference tables, and the lines of two adjacent tables are separated with a single line containing $75$ consecutive -
characters. The first line of a reference table contains the measurement name, a text of length at most $25$, which is unique among all the reference tables. The second line contains a text of length at most $15$ as the measurement unit. The remaining of the reference table describes its flag classification rules and is either a single line, or a set of pairs of lines. In the former case, the single line specifies the criteria for classifying the result as “Normal”. In this case, if the measurement result does not meet this criteria, it is classified as “Abnormal”. In the latter case where the remaining of the reference table is in the form of a non-empty set of (at most $10$) pairs of lines, the classification rules are more complex. In this case, the first line of each pair specifies the classification criteria, and the second line contains a text of length at most $25$ as the flag name preceded by two space characters. In any of the cases mentioned above, the classification criteria is a text of length at most 50 in one of the following forms ($A$ and $B$ are real numbers, and $x$ is a measurement result):
Criteria format | Meaning |
---|---|
$< A$ | $x < A$ |
$\leq A$ | $x \leq A$ |
$> A$ | $x > A$ |
$\geq A$ | $x \geq A$ |
$[A, B]$ or $A \sim B$ | $A \leq x \leq B$ |
$[A, B)$ | $A \leq x < B$ |
$(A, B]$ | $A < x \leq B$ |
$(A, B)$ | $A < x < B$ |
There might be arbitrary number of spaces between the different parts of a text specifying a classification criteria. So for example, $[2,5]$, $[ 2 , 5]$, and $2~ 5$ are valid and equivalent texts. When the flag classification rules of a reference table are described with a set of pairs of lines, it is guaranteed that the measurement value space is correctly partitioned by the given set of classification criteria; i.e., each possible measurement result matches exactly one of the provided classification criteria.
The next sections in the input specify the measurement results for the patients. The first line of each section contains a text of length at most $60$ as a patient’s name. Each of the next lines describes a measurement result for that patient with the measurement name and value (a real number) separated with an arbitrary number (between $1$ and $20$) of space characters. There are at least $1$ and at most $100$ measurement results for a single patient. Each measurement name appears at most once in the measurement results of a patient.
خروجی
For each section in the input except the first section (which describes the reference tables), you shall write the laboratory test report of its corresponding patient followed by a single line containing $80$ consecutive =
characters. A report consists of a line containing the patient’s name and a table depicting the test results. The table format is illustrative in the sample output. If there were $k$ measurements in the corresponding input section, this table should have $k+4$ lines of exact length $75$. All the empty areas shall be filled with the space character. The table has $4$ columns:
- Test: The measurement name; starting at the beginning of the line (the $1-st$ character).
- Result: The measurement result value, printed in the exact format as the input; starting at the $27-th$ character of the line.
- Unit: The measurement unit; starting at the $35-th$ character of the line.
- Flag: The classified flag based on the measurement result and the reference table; starting at the $51-st$ character of the line. Nothing (but space characters) should be written in this cell if the flag is “Normal”.
The measurement rows in the output table should be printed in the same order of appearance as in the corresponding input section. In addition to the measurement rows, the table should have a heading line and three separator lines (containing $75$ consecutive -
characters) as depicted in the sample output. Notice: The solutions for this problem are judged very strictly. In order for your output to be considered correct, all its characters, including the white space or upper/lower case letters, must exactly match the expected output.
مثال
ورودی نمونه ۱
Cholesterol
mg/dl
130~200
---------------------------------------------------------------------------
HDL-chol
mg/dl
>= 55
---------------------------------------------------------------------------
Fast Blood Sugar
mg/dl
<70
Hypoglycemia
70 ~ 99
Normal
(99, 126)
Impaired (Prediabetic)
>= 126
Diabetic
---------------------------------------------------------------------------
Secret Poison
mg/L
< 0.1
Noneffective
0.1 ~0.5
Mild
( 0.5 , 1.5 ]
Moderate
(1.5,5)
Severe
[5, 10]
Lethal (non-instant)
> 10
Instant Killer
================================================================================
Mr. Fat
Fast Blood Sugar 130
Cholesterol 230
HDL-chol 55
================================================================================
413%3! 4n@+01!3\/!(# /\/@\/@1n`/
Secret Poison 3.8
Cholesterol 150
================================================================================
Y@1d@ 49#@|=@21!
Fast Blood Sugar 90
Secret Poison 7.9
===============================
خروجی نمونه ۱
Mr. Fat
---------------------------------------------------------------------------
Test Result Unit Flag
---------------------------------------------------------------------------
Fast Blood Sugar 130 mg/dl Diabetic
Cholesterol 230 mg/dl Abnormal
HDL-chol 55 mg/dl
---------------------------------------------------------------------------
================================================================================
413%3! 4n@+01!3\/!(# /\/@\/@1n`/
---------------------------------------------------------------------------
Test Result Unit Flag
---------------------------------------------------------------------------
Secret Poison 3.8 mg/L Severe
Cholesterol 150 mg/dl
ارسال پاسخ برای این سؤال