Warehouse rush

After some time, Mio has finally found a job (she is terrible at finding jobs). She got a job in a warehouse, which is very similar to her last job, but this time, it is more brainy (last time it was all about cleaning).

She needs to count how many different products are stored in the warehouse. Unfortunately, warehouse can be enormous and Mio wants to be prepared for her job as soon as possible. This is where you step in.

Make a program that will do the counting. In input (input is through the file "warehouse.in") there will be few (10) simulations. The number of simulations is the firs number in the file. Input for each simulation is done in the following manner: Firstly, two positive integers \( m \) and \( n \), in this order, are given. In the following \( m \) rows, there will be \( n \) numbers. Each number \( { a }_{ i,j } \) (a number from row \( i \) and column \( j \)) represents the code of a product. Products with same codes are considered as the same. In the output, a number of different products for its simulation should be returned/written.

Sum of all countings (10 of them) shall be entered as the answer. Let's help Mio :)

The file can be downloaded by clicking here.

Useful information:

\( 1 \le m, n \le 1000 \)

\( 1 \le {a} _{ i,j } \le 10^{9} \)



3 4

19 12 12 18

14 16 16 1

4 10 18 13



If anything is left unclear, feel free to ask it here


Problem Loading...

Note Loading...

Set Loading...