Simulate fish that swim one unit away from a dolphin each step, and count how many trajectories hit the net polygon.
Medium6GeometrySimulationImplementationBrute forceNo attempts yetTime limit2sMemory limit512 MBDolphins are good at herding a school of fish so that the whole school swims in one direction. Some aboriginal tribes in Australia used that habit to fish together with wild dolphins. The dolphins drove a school toward the nets, the fishermen caught a large number of fish at once, and the fishermen shared the catch with the dolphins. Driving a whole school is much easier for a dolphin than catching fish one by one.
You are given the path of one dolphin, the starting positions of the fish, and the position of the net. Count how many fish the fishermen catch.
The simulation runs over t time steps in the plane. The position of the dolphin is given for every time step from 1 to t−1. At each of those steps every fish checks where the dolphin is and swims exactly distance 1 in a straight line, in the direction pointing from the dolphin to itself. The distance between a fish and the dolphin is always greater than 0.1.
The net is a polygon through n corners given in order, and the last corner joins back to the first, so the boundary is closed. The net never touches or overlaps itself. A fish is caught as soon as the segment it travels during one swim meets the boundary of the net in at least one point. Meeting at an endpoint of that segment, or at a corner of the net, counts as caught. A caught fish ends its simulation there and does not move again. No fish starts on the boundary of the net.
The first line contains the number of data sets K (1≤K≤10). Then K data sets follow, each in the form below.
The first line of a data set contains three integers n, f, t. n (3≤n≤100) is the number of corners of the net, f (0≤f≤100) is the number of fish, and t (1≤t≤100) is the number of time steps of the simulation.
The next line contains 2n real numbers a1, b1, a2, b2, ..., an, bn, the coordinates of the corners of the net in order.
The next line contains 2(t−1) real numbers p1, q1, ..., pt−1, qt−1, the positions of the dolphin at time steps 1 through t−1. This line is empty when t=1. The position of the dolphin at the last time step is not given because it does not affect the result.
Each of the next f lines contains two real numbers xi, yi, the position of fish i at time step 1.
All coordinates are between −1000 and 1000.
For each data set, first print Data Set x: on a line of its own, where x is the number of the data set counting from 1. On the next line print the number of fish caught. Print one blank line after each data set.