#K93302. Unique Animals in Trap Grid
Unique Animals in Trap Grid
Unique Animals in Trap Grid
You are given a grid of dimensions \(h \times w\) representing traps set at each cell. Each trap may capture several animals over time, and the records are kept in log entries. However, if the same animal is captured more than once at the same trap, it should only be counted once.
Your task is to process the logs and produce a grid where each cell contains the number of unique animals caught at that trap.
Input Format: The first line contains three integers \(h\), \(w\), and \(n\) which represent the number of rows, columns, and the number of log entries respectively. The next \(n\) lines each contain three integers: an animal's ID, \(x\) (the row index), and \(y\) (the column index). Note that the grid's indices are 1-based.
Output Format: Output \(h\) lines. Each line should contain \(w\) integers, where each integer represents the number of unique animals captured at that trap, with values separated by a single space.
inputFormat
Input is read from standard input (stdin). The first line contains three space-separated integers \(h\), \(w\), and \(n\). Each of the following \(n\) lines contains three space-separated integers: animal ID, \(x\), and \(y\), denoting a log entry.
outputFormat
Output the grid to standard output (stdout) in \(h\) lines. Each line contains \(w\) integers separated by a single space, where each integer is the count of unique animals at that trap.
## sample3 3 5
1 1 2
2 1 2
1 2 2
3 1 2
2 3 3
0 3 0
0 1 0
0 0 1
</p>