eolymp
bolt
Try our new interface for solving problems
Məsələlər

"Pieces of Paper"

"Pieces of Paper"

Edgy the Rabbit’s got a sheet of checked paper. The grid is aligned with the edges of the sheet. In particular, all four vertices of the sheet contain grid nodes in them. Edgy cuts the sheet along the grid with his scissors. Each cut is a straight line joining two grid nodes while parallel to the grid. Determine how many connected pieces of paper Edgy will have after each cut. \InputFile The first line of the input contains three positive integers: width of the sheet \textbf{w} (in grid units), height of the sheet \textbf{h}(in grid units) and the number of cuts \textbf{n} (\textbf{w} ≤ \textbf{200}, \textbf{h} ≤ \textbf{200}, \textbf{n} ≤ \textbf{2wh -- w -- h}). Each of the following \textbf{n} lines consists of four integers \textbf{x_1}, \textbf{y_1}, \textbf{x_2}, \textbf{y_2} where \textbf{(x_1, y_1)} and \textbf{(x_2, y_2)} are the endpoints of the cut. Here \textbf{0} ≤ \textbf{x_1} ≤ \textbf{x_2} ≤ \textbf{w}, \textbf{0} ≤ \textbf{y_1} ≤ \textbf{y_2} ≤ \textbf{h} and either \textbf{0} < \textbf{x_1 = x_2} < \textbf{w}, \textbf{y_1} < \textbf{y_2} or \textbf{0} < \textbf{y_1 = y_2} < \textbf{h}, \textbf{x_1} < \textbf{x_2}. No segment of the grid with non-zero length will be cut through more than once. \OutputFile For each cut output the number of connected pieces of paper after that cut. Each number’s to be put in a separate line.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
1 2 1
0 1 1 1
Çıxış verilənləri #1
2
Mənbə ACM-ICPC Ukraine 2013, 2nd Stage Ukraine, September 10-12, 2013