eolymp
bolt
Try our new interface for solving problems
Problems

Chupacabras vs mothmen

Chupacabras vs mothmen

The arena is a square field with \textbf{N}×\textbf{N} cells. Chupacabras and mothmen are positioned on the grid. Each of the chupacabras and mothmen has "power" defined by a nonnegative integer; the chupacabras have even power numbers and the mothmen have odd numbers. Chupacabras always move from right to left, and mothmen always move from left to right. When a chupacabra collides with a mothman, the stronger one wins, and the weaker one disappears from the arena. A chupacabra cannot jump over or step on another chupacabra; the same goes for two mothmen. Define how many chupacabras and mothmen will remain on the arena when no further motion is possible. \InputFile The first line of the input file contains a single integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100}). The following \textbf{N} lines each contain \textbf{N} numbers separated by spaces. The \textbf{j}-th symbol of the \textbf{i}-th line denotes the "power" of a chupacabra or a mothman situated in the cell with the coordinates (\textbf{i}, \textbf{j}), or equals \textbf{-1} if the cell is empty. The values of numbers denoting power are equal or lower than \textbf{100}. \OutputFile The output file must contain two numbers separated by a space --- the number of the remaining chupacabras and mothmen, correspondingly.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
5 -1 4 -1
3 -1 1 -1
-1 2 -1 4
-1 -1 -1 -1
Output example #1
2 3
Source XIII All-Siberian Programming Contest named after I.V.Pottosin, November 11, 2012