Logo
(追記) (追記ここまで)

32043번 - Toy 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.35 초 1024 MB42232255.000%

문제

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 \times W$ grid containing a metal object consisting of two parts: A horizontal 1ドル\times K$ part and a vertical $L \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 $W,ドル $H,ドル $K$ and $L$ — 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_h,ドル $y_h,ドル $x_v$ and $y_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 0ドル$ to $H-1$ from top to bottom and columns are numbered 0ドル$ to $W-1$ from left to right. The $x$ coordinate denotes the column number and $y$ coordinate denotes the row number.

The next $H$ lines contain $W$ 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ドル \leq W, H \leq 1,500円$
  • 2ドル \leq K \leq W,ドル 2ドル \leq L \leq H$
  • 0ドル \leq x_h \leq W - K,ドル 0ドル \leq y_h \leq H - 1$
  • 0ドル \leq x_v \leq W - 1,ドル 0ドル \leq y_v \leq H - L$

서브태스크

번호배점제한
114

$W, H \le 50$

221

$W, H \le 90$

39

$W, H \le 300$ and $K, L \le 10$

429

$W, H \le 360$

527

no additional constraints

예제 입력 1

4 3 2 2
0 1 0 0
.X.*
....
...X

예제 출력 1

YES

The initial situation looks as follows:

We can reach the target square by first moving the vertical part one square down, followed by alternating movement to the right of the vertical and horizontal parts as long as possible. Then we can move the vertical part up and to the right, reaching the target square, and finally move the horizontal part up, reaching the target as well.

예제 입력 2

2 3 2 3
0 1 0 0
.X
.*
.X

예제 출력 2

NO

There is no way how to move the vertical part without running into an obstacle. Therefore, it can never reach the target square.

힌트

출처

Olympiad > Central European Olympiad in Informatics > CEOI 2024 > Day 2 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /