Ambulance

시간 제한2초메모리 제한2048 MB

요약
네 모서리에서 출발하는 구급차로 N명의 환자를 모두 시간 T 안에 병원으로 옮길 수 있는지 판정한다.
난이도

어려움10점 중 8점

유형
그래프, 동적 계획법, 그리디, 이분 탐색
정답자
아직 제출이 없습니다

문제

The IOI Kingdom is represented as a square grid of LL rows and LL columns. The rows are numbered 1,2,…,L1, 2, \dots , L from top to bottom and the columns are numbered 1,2,…,L1, 2, \dots , L from left to right. A cell at row ii (1≤i≤L1 ≤ i ≤ L) and column jj (1≤j≤L1 ≤ j ≤ L) is denoted as cell (i,j)(i, j).

Recently, due to a widespread infection in the IOI Kingdom, the demand for improved medical facilities has increased. In response, the king, Bitaro, has decided to build hospitals in the four corners of the grid, which are cell (1,1)(1, 1), cell (1,L)(1, L), cell (L,1)(L, 1), and cell (L,L)(L, L). Each hospital is equipped with one ambulance.

The cautious Bitaro decided to run a simulation to prepare for actual emergency calls from patients. In the scenario he envisioned, emergency calls from NN patients arrive at time 00, and he wants to determine whether all patients can be transported to one of the hospitals by time TT. The kk-th patient (1≤k≤N1 ≤ k ≤ N) is located at cell (X_k,Y_k)(X\_k, Y\_k).

The ambulances transport patients according to the following rules:

  • Each ambulance can start moving at time 00 or later. It repeats the following (possibly 00 times): depart from its hospital, move to the patient’s location, pick up the patient, and then return to the hospital to drop off the patient.
  • Each ambulance can carry at most 11 patient at a time.
  • Each ambulance can only transport patients to the hospital where it was initially stationed. Patients cannot be dropped off at any location other than a hospital.
  • Each ambulance moves to an adjacent cell (up, down, left, or right) in 11 unit of time. The time taken to pick up and drop off a patient can be ignored.
  • Ambulances from different hospitals may occupy the same cell at the same time.

Unfortunately, Bitaro was unable to determine the outcome of his envisioned scenario, so he has asked you to investigate it on his behalf.

Given the size of the IOI Kingdom and the scenario envisioned by Bitaro, write a program to determine whether all patients can be transported to a hospital by time TT.

입력

The input is given from Standard Input in the following format:

LL NN TT

X_1X\_1 Y_1Y\_1

X_2X\_2 Y_2Y\_2

⋮\vdots

X_NX\_N Y_NY\_N

출력

Print Yes if all patients can be transported to a hospital by time TT in the scenario envisioned by Bitaro. Otherwise, print No. The output should consist of a single line.

제한

  • 3≤L≤10,0003 ≤ L ≤ 10\\, 000.
  • 1≤N≤1601 ≤ N ≤ 160.
  • 1≤T≤20,0001 ≤ T ≤ 20\\, 000.
  • 1≤X_k≤L1 ≤ X\_k ≤ L (1≤k≤N1 ≤ k ≤ N)
  • 1≤Y_k≤L1 ≤ Y\_k ≤ L (1≤k≤N1 ≤ k ≤ N)
  • (X_k,Y_k)(X\_k, Y\_k) is not equal to any of (1,1)(1, 1), (1,L)(1, L), (L,1)(L, 1), or (L,L)(L, L). (1≤k≤N1 ≤ k ≤ N)
  • All input values are integers.

예제4

  1. 예제 1

    입력
    6 4 8
    1 3
    2 2
    3 4
    5 5
    
    예상 출력
    Yes
    
  2. 예제 2

    입력
    9 5 19
    5 5
    5 5
    7 5
    2 5
    9 5
    
    예상 출력
    No
    
  3. 예제 3

    입력
    7 7 16
    6 1
    2 4
    4 5
    5 5
    3 4
    6 4
    5 1
    
    예상 출력
    Yes
    
  4. 예제 4

    입력
    200 15 800
    126 45
    196 40
    43 58
    96 13
    28 33
    44 55
    60 22
    58 156
    135 183
    44 29
    92 182
    157 138
    30 132
    175 87
    166 57
    
    예상 출력
    No