Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Infinity Wall

By zobayer · Limits 1s, 512 MB

Alien Tara lives on a planet named Confusious. He wants to go to the planet Ultron. He can use any spaceship for going to Ultron. But he is afraid of the infinity wall. No spaceship can go through this infinity wall. The breath of the wall is negligible. If Confusious and Ultron are on different sides of the wall Tara can never reach Ultron. So Tara wants to know whether or not he can go to Ultron. Tara only knows three coordinates of the wall and the coordinates of both planets. He is confirmed that all three coordinates of the wall are not collinear. He is not good at Math. For that reason, he wants your help. To make the problem simpler you can consider every planet as a point. No planet lies on the surface of the infinity wall.


Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each set of input contains five lines. Each line contains 3 integers giving the x, y, and z coordinates of a single point (-2<=x, y, z <= 10000). First-line contains the coordinates of Confusious, the second line contains the coordinates of Ultron, and the remaining three lines contain the coordinates of three points of the Infinity wall.


For each test case, print a line in the format, "Case P: Q", where P is the case number & Q is "YES" or "NO". See sample output format.


1 1 1
2 2 2
2 3 0
0 0 0
1 0 0
1 1 1
2 2 -2
2 3 0
0 0 0
1 0 0
Case 1: YES
Case 2: NO



    50% Solution Ratio

    Deshi_TouristEarliest, 3w ago

    Deshi_TouristFastest, 0.0s

    Deshi_TouristLightest, 262 kB

    Deshi_TouristShortest, 8263B


    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.