Nội dung Bài tập
Mã:
r2.b3.Hereditament
Tên:
Hereditament
Dạng thi:
oi
Thang điểm:
10 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
64 MB
Được tạo bởi:
admin
A farmer has a land in shape of rectangle has size nxm. He wants to divides his land to give to his k sons (labeled from 1 to k). Dividing process splits the land into smaller equal squares with length 1.
At first, each son will choose 1 square (No one choose same square as others). One son will expand his land by adding others square, which have same edge with their squares collected before in turn by their label until all squares are owned. It means that, they will turn around by their label to expand their land: Son with label 1 will choose first, continue with label 2,…. After label k chose, it turns again to label 1 until all squares are chosen.
Taking it faster, you suggest that you will determine number squares of each son has after this process.

Input
The first line of the input contains three positive integers n and m and k, where n,m ≤ 105 is the size of the land, and 2 ≤ k ≤ 10 is number of son. Next k lines each line ith contain 2 positive integers u and v that describe the location of first square of son ith by index of row and column.
Output
Output k respective lines with number of squares of each son.

Sample input

Sample output

4 7 3

1 2

3 6

4 3

11

12

5



Explanation for sample

1

1*

1

1

1

2

2

1

1

1

1

2

2

2

1

1

3

2

2

2*

2

3

3

3*

3

2

2

2



    Quảng cáo
       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận