[BOJ 7916] Cross Spider
View as PDFThe Bytean cross spider (Araneida baitoida) is known to have an amazing ability. Namely, it can instantly build an arbitrarily large spiderweb as long as it is contained in a single plane. This ability gives the spider an opportunity to use a fancy hunting strategy. It does not need to wait until a fly is caught in an already built spiderweb; if only the spider knows the current position of a fly, it can instantly build a spiderweb to catch the fly.</p>
A cross spider has just spotted n flies in Byteasar’s garden. Each fly is flying still in some point of a 3D space. The spider is wondering if it can catch all the flies with a single spiderweb. Write a program that answers the spider’s question.
입력 형식
The first line of the input contains an integer n (1 ≤ n ≤ 100 000). The following n lines contain a description of the flies in a 3D space: the i-th line contains three integers xi, yi, zi (−1 000 000 , xi, yi, zi , 1 000 000) giving the coordinates of the i-th fly (a point in a 3-dimensional Euclidean space). No two flies are located in the same point.
출력 형식
Your program should output a single word TAK (i.e., yes in Polish) if the spider can catch all the flies with a single spiderweb. Otherwise your program should output the word NIE (no in Polish).
예제 입력 1
4
0 0 0
-1 0 -100
100 0 231
5 0 15
예제 출력 1
TAK
예제 입력 2
4
0 1 0
-1 0 -100
100 0 231
5 0 15
예제 출력 2
NIE
Comments