ZOJ Problem Set - 1816
In the land of Kalii lived a civilization not unlike our own. They had government, business, and technology. The only major difference was how tax rates were decided. You see, the people of Kalii loved to haggle. They haggled over everything including what percentage of their income went to the government coffers. When a Kalii family's tax contract was up they had to travel to the capital to haggle with government officals and hammer out a new deal. The contract would have a start date, an end date (for bookkeeping purposes the end day was always the 15th of the end month), and a tax rate. It was also traditional for a Kalii family to enjoy a short time period of tax free living between the end of their last contract and the start of the new one. This time period was a point to haggle over as well.
The land of Kalii was prosperous and very populous and, as a consequence, government officials were often overwhelmed with work. When a deal was agreed upon with a family, the officials would quickly write it down in shorthand and send it off to be processed. These scribbled notes had to be converted to XML format to be entered into their computer system. Sometimes the scribble was inconclusive and the family would have to be recalled to the capital for another round of haggling. This entire process was very inefficient but it was the way the people of Kalii had always done it and they were not about to change anytime soon.
Your job is to convert the scribblings of the officials into XML format.
Input consists of multiple datasets, one per line. Each correct line contains three pieces of information:
1. Tax rate
- A tax rate always has a '%' after it if it is a whole number (i.e. 5%).
2. Contract End Date
- A contract end date is a numerical representation of the month (one or two digits) and the last two digits of the year. The month and year may be separated by a single hyphen (i.e. 12-05 or 1205 would refer to 15DEC05).
3. Contract Start Date
- A contract start date is a numerical representation of the month (one or
two digits) and a two-digit day of the month. The month and day may be separated
by a single hyphen (i.e. 12-05 or 1205 would refer to 05DEC03).
Note: There may be 0 or more spaces between each of the three fields.
For each data set, print the correctly indented XML (4 spaces per indent level):
<Kalii Index=N >
N should be replaced by the data set number, (start date) by the start date, (tax rate) by the tax rate, and (end date) by the end date. If no output could be computed because of either bad or ambiguous data, simply print <Kalii Index=N >BAD DATA</Kalii>, where N should be replaced by the data set number.
Note: The format for the start date is DDMMMYY. The format for the end date
is 15MMMYY. Where DD is the zero-padded day of month (01-31), MMM is the month
in upper-case letters (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV,
DEC), and YY is the zero-padded last 2 digits of the year (00-99).
Source: Greater New York 2003