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

Galactic Warlords

Galactic Warlords

\includegraphics{https://static.e-olymp.com/content/4f/4f4de4513e9243378bc943df00114592d19ca086.jpg} \textit{Correct version} Will the galaxy see peace at last? All the warlords have gathered to divide all of space between themselves. The negotiations have come quite far and the warlords have finally agreed on a peaceful way of deciding who gets what. The 2-dimensional galactic map must first be divided into sectors by splitting it along a set of infinite lines. The warlord with the largest battle fleet will choose one sector, then the warlord with the second largest fleet will choose some other sector and so on, until everyone has gotten a sector. This is then repeated until there are no sectors left. Different sets of lines have been suggested, and it is up to you to present these alternatives to the meeting. To make sure that there will be peace, you are ready to modify the suggestions slightly. You have some experience with warlords and know that no warlord will settle for less space than anyone else, so for there to be peace, all of them must get the exact same area on the map. Since space is infinite, so is the map. Some sectors will therefore have infinite area, so that is the amount of space everyone will want. How many extra lines will you have to add to make sure each warlord can get at least one sector with infinite area? \InputFile The first line of input contains two positive integers \textbf{W} and \textbf{N}, (\textbf{1} ≤ \textbf{W}, \textbf{N} ≤ \textbf{100}) denoting the number of warlords and the number of lines in the suggested division of space. This is followed by \textbf{N} lines each containing four integers \textbf{x_1}, \textbf{y_1}, \textbf{x_2} and \textbf{y_2}, each with an absolute value no higher than \textbf{10000}. This means that one line is intersecting the two points (\textbf{x_1}, \textbf{y_1}) and (\textbf{x_2}, \textbf{y_2}) on the galactic map. These two points will not be the same. \OutputFile Output the number of lines you will have to add to this suggestion to satisfy all warlords.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
2 1
1 1 -2 0
Çıxış verilənləri #1
0
Mənbə ACM ICPC NCPC 2012, 6th October 2012