PEG Test – Oct 3rd, 2014

Problem B: Earth

Earthbending is an art which allows its users to manipulate earth and rocks in all of their various forms. Earthbenders are strong, persistent, and enduring people. The secret to being a good earthbender is waiting and listening for the right moment to strike decisively.

Aang, Katara, and Sokka are currently scouring the entire earth kingdom in search of a proper earthbending teacher for Aang. In the town of Gaoling, they have stumbled upon the Blind Bandit (i.e. a young, blind girl named Toph from a rich earth-kingdom family) in an earthbending tournament with The Boulder. Aang immediately knew that Toph was the one after she effortlessly defeated the boulder, but incidently defeated Toph with his airbending to claim the prize money himself after failing to convince her. Bitter about losing the prize money, the Boulder gathered the other earthbenders of the tournament and kidnapped Aang. Toph decides to rescue Aang and confronts The Boulder. Now, she must face the wrath of a giant earthbending wrestler who is closing in on her.

No sweat! It's the perfect time for Toph to test out her new technique – the Earth Cage. Toph creates an earth cage by erecting 4 rocky walls on the 2D-plane such that they form a rectangle whose sides are parallel to the X and Y axes. However, because Toph is blind, she cannot be instantly sure if her earth cage has trapped her opponent.

Given The Boulder's position and the locations of the the four walls of the earth cage, determine if Toph has successfully trapped him. The Boulder will always be directly inside or outside of the walls.

Input Format

The first line contains two integers x and y, representing the coordinates of The Boulder at the moment Toph raises the walls.
The second line contains four integers x1, y1, x2, and y2 (1 ≤ x1 < x2 ≤ 107; 1 ≤ y1 < y2 ≤ 107), the locations of the walls.
x1 and x2 are the x-coordinates of the vertical walls while y1 and y2 are the y-coordinates of the horizontal walls.

Output Format

Output Yes if The Boulder is trapped, or No otherwise.

Sample Input

4 6
3 5 5 7

Sample Output

Yes

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 06, 2014
Authors: Alex, frenzybenzy

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

im getting the sample correct, what is the problem with the code

You are overcomplicating your if statements. Just because it works on samples doesn't guarantee that it will work on system tests.

I believe test case number four is wrong!

Like they always say look at the amount of people with perfect solutions. You might be right, but 16 others got it so?

Input for case 4 is:

[--snip--]

and says the answer is [--snip--]

That is correct. Read the input format carefully.