#K5441. Snowball Fight Winner
Snowball Fight Winner
Snowball Fight Winner
In this problem, Tim and Jerry are engaged in a snowball fight. Each of them throws snowballs, and each throw can either be a hit or a miss. You are given two sequences representing the outcome of the throws for Tim and Jerry. The task is to determine the winner as follows:
- If the number of hits (i.e. occurrences of
hit
) in Tim's sequence is greater than in Jerry's, Tim wins (output0
). - If the number of hits in Jerry's sequence is greater than in Tim's, Jerry wins (output
1
). - If both have an equal number of hits (including when both sequences are empty), the result is a draw (output
-1
).
Mathematically, if we denote the number of hits for Tim by \( H_{tim} \) and for Jerry by \( H_{jerry} \), the result is determined by:
[ result = \begin{cases} 0, & \text{if } H_{tim} > H_{jerry} \ 1, & \text{if } H_{jerry} > H_{tim} \ -1, & \text{if } H_{tim} = H_{jerry} \end{cases} ]
Please note that the input will be provided via STDIN and the output should be printed to STDOUT.
inputFormat
The input consists of two lines:
- The first line contains the outcomes for Tim's throws, separated by spaces.
- The second line contains the outcomes for Jerry's throws, separated by spaces.
Each outcome is either hit
or miss
. If a line is empty, it represents an empty sequence.
outputFormat
Print a single integer to STDOUT:
0
if Tim wins.1
if Jerry wins.-1
if the fight is a draw.
hit miss hit
miss hit miss
0