Alcatraz

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

요약
가로 w, 세로 h인 영역에서 감시 범위가 원인 경비병들을 피해 (0,0)에서 (w,h)까지 이동할 수 있는지 판정한다.
난이도

보통10점 중 5점

유형
그래프, 유니온 파인드, 기하
정답자
아직 제출이 없습니다

문제

After breaking into the database of the TU Delft and releasing sensitive information to the public, Anton the cyber criminal got the CIA looking for him. After being arrested, Anton was transported to the heavily guarded prison Alcatraz. Disabling the security system was a piece of cake, so he could easily get outside of the prison walls. However, behind these walls a number of guards are positioned and they will immediately sound the alarm if they spot any escaped prisoner.

To escape, Anton needs to cross a field with width ww and height hh that is being guarded by nn guards, without being spotted by any of the guards. He starts at position (0,0)(0,0) and can only escape if he reaches position (w,h)(w,h) without being spotted. Even if the criminal is only spotted at position (n,n)(n,n) the guards will sound the alarm and he will be captured. Some guards have better views that others, so every guard ii has an associated range of view r_ir\_i. If the distance between the guard and the escaped prisoner is r_ir\_i or less, the guard will sound the alarm and the prisoner will return to his cell.

Your job is now to find out whether Anton can escape Alcatraz or if he cannot escape without being spotted. If he can escape, output ESCAPE. Otherwise output NO ESCAPE.

입력

  • A line with 3 integers:

    • ww: the width of the area (1≤w≤100)(1 \leq w \leq 100).
    • hh: the height of the area (1≤h≤100)(1 \leq h \leq 100).
    • gg: the number of guards (0≤g≤100)(0 \leq g \leq 100).
  • nn lines (i=1…n)(i=1\dots n) with 3 integers each:

    • x_ix\_i: the xx-coordinate of the ithi^{th} guard (0≤x_i≤w)(0 \leq x\_i \leq w).
    • y_iy\_i: the yy-coordinate of the ithi^{th} guard (0≤y_i≤h)(0 \leq y\_i \leq h).
    • r_ir\_i: the range of the ithi^{th} guard's vision (0≤r_i≤100)(0 \leq r\_i \leq 100).

출력

ESCAPE if the prisoner can escape Alcatraz, NO ESCAPE otherwise.

예제2

  1. 예제 1

    입력
    5 5 3
    3 1 2
    3 5 1
    1 4 1
    
    예상 출력
    ESCAPE
    
  2. 예제 2

    입력
    5 5 3
    3 1 2
    3 4 1
    1 4 1
    
    예상 출력
    NO ESCAPE