## LCC/Moose '20 Contest 5 S4 - Ninjaclasher's Mobs

View as PDF

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Ninjaclasher is playing minecraft! He has mobs in his farm, each with a type from to . There is at least one mob of each type. He wants to become more organized, so he wants to build a pen for one of his mobs. Specifically, he wants his pen to enclose all the mobs of some type , yet not enclose any mobs not of type . He also wants to be able to walk in a straight line from his base to his mine without having to go through more than fence gates. However, you do not know where his base or his mine are (that is a secret), so you want to build the enclosure such that no matter where his base and his mine are, he can walk from his base to his mine without crossing the enclosure boundary more than twice. Can you help him determine if this is possible? As the farm is gigantic, you can assume the plane is continuous (i.e. there is an arbitrarily large number of blocks in for ).

#### Input Specification

The first line will contain two integers , the number of mobs, and the number of different types of mobs.

The next lines will contain integers , the position and type of each mob.

#### Output Specification

Print YES if some mob can be enclosed, or NO otherwise.

No further constraints.

#### Sample Input

6 2
0 0 1
2 2 1
2 0 1
1 1 2
2 3 2
3 1 2

#### Sample Output

NO