아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Solnedgång

시간 제한9초메모리 제한1024 MB

요약
그림자가 시간마다 북쪽으로 한 칸씩 늘어날 때, 집 1에서 집 N까지 그림자만 지나는 경로가 생기는 최소 시간을 구하고 K 이상이면 NATT를 출력합니다.
난이도

보통10점 중 6점

유형
그래프, BFS, 시뮬레이션, 기하
정답자
아직 제출이 없습니다

문제

You are visiting a very warm country, and it happens to be a sizzling hot day. Luckily, you managed to find the shadow of a house to take cover in. You realize that you probably should head back to the hotel sometime soon, but you also realize that it's too hot to walk in the sun. The city you are in consists of NN houses, placed in a grid, where every house occupies exactly one unit square.

Currently, each house has a shadow that is exactly one unit square long, and is located directly north of the house. Since the sun just started to set, this shadow will extend one more unit square north per time unit. You can walk from the shadow of one house to another one, if the shadows share an edge of length at least one (see figure). You cannot walk through houses.

The question is how long it will take before there exists a path to the hotel that does not involve getting burned by the sun. The hotel is house number NN, and you are currently in the shadow of house number 1. Since the hotel entrence is at the north side of the house, that's where you need to go. In the worst case you might have to wait until nightfall, which will occur in KK units of time.

입력

The first line contains two space-separated integers NN and KK - the number of houses in the city and the number of time units before nightfall.

The next NN lines contains 2 integers xyx y each, the coordinates of the houses. The first line contains the coordinates of the house which you take cover behind, and the last line contains the coordinate of the hotel.

It is guaranteed that every house has a shadow, i.e. no house is placed immediately south of another house.

출력

You should output a single integer, the time it takes before there exist a path to the hotell which goes entirely through the shadows, or "NATT" in case this time exceeds or equals KK.

제한

  • 1≤N1 \le N
  • 0≤K0 \le K

예제3

  1. 예제 1

    입력
    4 10
    0 1
    1 2
    2 0
    3 2
    
    예상 출력
    2
    
  2. 예제 2

    입력
    8 10
    1 0
    2 1
    3 1
    4 1
    2 4
    3 4
    1 5
    0 4
    
    예상 출력
    3
    
  3. 예제 3

    입력
    2 100
    1 0
    3 0
    
    예상 출력
    NATT