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

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

Toy

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

요약
장애물이 있는 격자에서 가로막대와 세로막대로 된 금속 조각을 움직여 두 부분이 목표 칸에서 겹치게 할 수 있는지 판정한다.
난이도

보통10점 중 7점

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

문제

For creating a task for CEOI 2024, Ben was given a toy as a present from the scientific committee. The toy is a puzzle which can be imagined as a H×WH \times W grid containing a metal object consisting of two parts: A horizontal 1×K1\times K part and a vertical L×1L \times 1 part, which are loosely attached to each other. Neither of the parts can be rotated in any way, but each can be slid vertically or horizontally independently of the other one, as long as they always overlap on exactly one square.

Furthermore, the grid contains several obstacles. No part of the metal object can move through an obstacle. Worse yet, the parts also cannot move outside the grid, not even partially. Ben's task is to move the metal object from a designated starting location to a (possibly) different location so that both parts overlap on a designated target square.

However, Ben has been playing with the toy for a while and he has not yet been able to solve the task. In fact, he has gained a suspicion that the organizers have played a prank on him and have given him an unsolvable puzzle. He thus asks for your help by telling him whether the puzzle is solvable or not.

입력

The first line of the input contains four space-separated integers WW, HH, KK and LL — the width and the height of the puzzle, the width of the horizontal part and the height of the vertical part, respectively. The second line contains four integers x_hx\_h, y_hy\_h, x_vx\_v and y_vy\_v — the coordinates of the leftmost square occupied by the horizontal part and the coordinates of the topmost square occupied by the vertical part.

The rows are numbered from 00 to H−1H-1 from top to bottom and columns are numbered 00 to W−1W-1 from left to right. The xx coordinate denotes the column number and yy coordinate denotes the row number.

The next HH lines contain WW characters each, representing the grid. The character . represents an empty square, the character X represents an obstacle and the character *represents the target square.

It is guaranteed that the initial position of the metal object is valid, i.e., that the two parts overlap on exactly one square and the two parts neither overlap with an obstacle nor stick out from the grid.

There is a single target square, i.e., a single occurrence of the *symbol in the toy, which might overlap with the initial position of the metal object.

출력

Print a single line containing YES if it is possible to move the metal object to the target square, NO otherwise.

제한

  • 2≤W,H≤1,5002 \leq W, H \leq 1\\,500
  • 2≤K≤W2 \leq K \leq W, 2≤L≤H2 \leq L \leq H
  • 0≤x_h≤W−K0 \leq x\_h \leq W - K, 0≤y_h≤H−10 \leq y\_h \leq H - 1
  • 0≤x_v≤W−10 \leq x\_v \leq W - 1, 0≤y_v≤H−L0 \leq y\_v \leq H - L

예제2

  1. 예제 1

    입력
    4 3 2 2
    0 1 0 0
    .X.*
    ....
    ...X
    
    예상 출력
    YES
    
  2. 예제 2

    입력
    2 3 2 3
    0 1 0 0
    .X
    .*
    .X
    
    예상 출력
    NO