Two Dots
Time limit1sMemory limit1024 MB
Given colored points on an L by L square, decide whether every same-colored pair can be joined by non-crossing curves inside the square.
- Level
Hard8 of 10
- Topics
- Geometry, Sorting, Stack, Union-find
- Solved
- No attempts yet
Problem
"Only 1% can solve this problem!!!"
One day, Yunee saw an advertisement for the game named "Two Dots". The goal of this game is to connect all pairs of points with the same colors.
The rules are as follows. The game area is a square of size . points are on the square, some completely inside and others on the boundary. They are divided into pairs by their colors. You can connect a pair of points by drawing a curved line between them. The lines must lie completely inside the square and must never cross each other.
Yunee found that the problem in the advertisement can never be solved. Yunee is angry about this and plans to report the ad as false by proving that the problem cannot be solved. If the problem cannot be solved, then only 0% can solve this problem!!!
Write a program that determines whether the given problem can be solved.

Input
The first line contains an integer and an even integer . is the side length of the game area and is the number of points. The four vertices of the game area are , , , and .
The next lines describe the points. The -th line contains the coordinates and the color of the -th point . The coordinates of the points are distinct. There are exactly two points with each color .
Output
Output 1% if the problem can be solved, and 0% otherwise.