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

A Walk in the Park

A Walk in the Park

You are responsible for inspecting the trees located in a park, to make sure they remain healthy. The location of each tree is given to you as a point in the two dimensional plane, distinct from that of every other tree. Due to recentlyreplanted grass, you are only allowed to walk through the park along a collection of paths. Each path is described by an infinite-length horizontal or vertical line in the two-dimensional plane. No tree lies on any path. You are concerned that it may not be possible to view all the trees in the park from the paths. In particular, a tree is visible only if you can view it by standing on some path while facing in a direction perpendicular to that path; there must be no intervening tree that obstructs your view. Given the geometrical configuration of the park, please report the number of visible trees. \InputFile There will be multiple input sets. For each input set, the first line will contain two integers, \textbf{N} and \textbf{M}, (\textbf{0} < \textbf{N}, \textbf{M} <= \textbf{100000}), separated by a space. \textbf{N} is the number of trees, and \textbf{M} is the number of paths. The next \textbf{N} lines each contain two space-separated integers, \textbf{X} and \textbf{Y}, specifying the coordinates of a tree. \textbf{X} and \textbf{Y} may be any \textbf{32}-bit integers. The next \textbf{M} lines each describe a path (a vertical or horizontal line). They have the form \textbf{x} = \textbf{K} or \textbf{y} = \textbf{K}, with no spaces. \textbf{K} may be any \textbf{32}-bit integer. x and y will be lower case. End of the input is signified by a line with two space-separated \textbf{0}'s. \OutputFile For each input set, print a single line containing one integer, specifying the number of visible trees. There should be no blank lines between outputs.
Zaman məhdudiyyəti 10 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
6 3
-1 3
4 2
6 2
6 3
6 4
4 3
x=0
y=-1
y=5
1 2
2 3
x=5
y=5
0 0
Çıxış verilənləri #1
5
1