Flowey's Love
Time limit1sMemory limit512 MB
A soul starting at the origin moves at speed at most 1 inside a rectangle; N moving points travel along fixed lines, and you must find the maximum number of points the soul can touch.
- Level
Hard9 of 10
- Topics
- Geometry, Dynamic programming, Bit manipulation, Math
- Solved
- No attempts yet
Problem
Flowey: Howdy! I'm Flowey, Flowey the flower! You're new to the underground, aren't you? Golly, you must be so confused. Someone ought to teach you how things work around here! I guess little old me will have to do. Ready? Here we go!

Flowey: See that heart? That is your SOUL, the very culmination of your being! Your SOUL is weak, but it can grow strong if you gain a lot of LV. What does LV stand for? Why, LOVE, of course! You want some LOVE, don't you?
Flowey: Don't worry, I'll share some with you! Down here, we share little white friendliness pellets. Move around! Get as much friendliness as you can!

Flowey scattered friendliness pellets. Every pellet moves along a straight line at speed . Your soul is at the origin at time and moves in any direction at a speed of at most . The speed can be any value, such as or , and the soul may also stay where it is. The soul cannot leave the rectangle given by and .
A pellet vanishes the moment it touches your soul, and that pellet counts as collected, so you collect at most of them. The soul and the pellets are points. Given the pellets, write a program that finds the largest number of friendliness pellets you can collect.
Input
The first line contains the number of friendliness pellets and two integers , that describe the region the soul can move in (, ).
Each of the next lines contains four integers , , , describing one pellet (). The pellet is at at time and moves along a straight line toward , and it keeps moving in the same direction after it passes . and are different points, and is never the origin.
Output
Print the largest number of friendliness pellets you can collect.