Mowing the Lawn

Time limit1sMemory limit128 MB

Summary
Determine if sorted mower path coordinates with a given strip width fully cover a 75x100 rectangle in both directions, across multiple test cases until a terminator line.
Level

Easy3 of 10

Topics
Sorting, Simulation, Intervals
Solved
No attempts yet

Problem

The International Collegiate Soccer Championship (ICSC) is famous for its immaculately kept rectangular pitch. The grass of an ICSC pitch is always 100 metres long and 75 metres wide. The mowing is done every week by a special operator who always uses the same method: they choose several paths parallel to the width direction and to the length direction of the pitch, and mow the grass while moving along those paths.

ICSC has hired a new operator, Sujin. Sujin loves chaos, so instead of covering the pitch in order she likes to pick her paths at random. Afraid of doing a poor job and being fired by ICSC, she has asked you for help.

Help Sujin by writing a program that checks whether the grass of the pitch has been mowed perfectly. The grass is mowed perfectly when every point of the pitch has been cut at least once in the width direction and at least once in the length direction.

The mowing machine has width ww, so mowing a path cuts a strip of width ww centred on that path, with both edges of the strip included. In other words, a path at coordinate cc cuts everything within w/2w/2 of cc.

Input

Each test case consists of 3 lines.

The first line contains two integers nxnx (0<nx<10000 < nx < 1000) and nyny (0<ny<10000 < ny < 1000), followed by the mowing width ww (0<w≤500 < w \le 50).

The second line contains the nxnx real coordinates xix_i (0≤xi≤750 \le x_i \le 75) of the paths mown parallel to the width direction.

The third line contains the nyny real coordinates yiy_i (0≤yi≤1000 \le y_i \le 100) of the paths mown parallel to the length direction.

The input ends with a line 0 0 0.0.

The real numbers ww, xix_i, and yiy_i are given with up to 7 digits after the decimal point, and when mowing, the edges of the cut region are included.

Output

For each test case, print YES if Sujin mowed the grass perfectly, and NO otherwise.

Examples1

  1. Example 1

    Input
    8 11 10.0
    0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0
    0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0
    8 10 10.0
    0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0
    0.0 10.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0
    4 5 20.0
    70.0 10.0 30.0 50.0
    30.0 10.0 90.0 50.0 70.0
    4 5 20.0
    60.0 10.0 30.0 50.0
    30.0 10.0 90.0 50.0 70.0
    0 0 0.0
    
    Expected output
    YES
    NO
    YES
    NO