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

34638번 - Carl's Maze-Solving Algorithm 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB129872.727%

문제

Carl the ant is back! After traveling around some pyramids, Carl has decided to study some algorithms and has invented a novel algorithm for solving grid mazes. It works as follows:

  • Carl starts somewhere in the maze facing to the right and wants to get to a destination square.
  • While Carl is not yet in the destination square.
    • If Carl can turn left by 90 degrees and face an empty square, he will turn left 90 degrees and then move forward by one square.
    • Otherwise, if Carl can move forward by one square, he will do so.
    • Otherwise, he will turn right 90 degrees.

Carl wants to know if this algorithm works. Help him check!

입력

The first line of input contains two integers, $r$ and $c$ $(1 \le r, c \le 50),ドル indicating the size (rows, columns) of the maze. The cell at $(1,1)$ is the top left corner of the maze.

The next line of input contains two integers, $i_{start}$ and $j_{start}$ $(1 \le i_{start} \le r, 1 \le j_{start} \le c),ドル the starting location for Carl in row $i_{start},ドル column $j_{start}$.

The next line of input contains two integers, $i_{end}$ and $j_{end}$ $(1 \le i_{end} \le r, 1 \le j_{end} \le c),ドル the desired ending location for Carl in row $i_{end},ドル column $j_{end}$. It is guaranteed the starting location and desired ending location for Carl are different.

Each of the next $r$ lines contains a string of $c$ characters, consisting only of 0 or 1. If the character is 1, then that square has an obstacle in it and cannot be traversed, otherwise it is empty. It is guaranteed that Carl’s starting location and desired ending location are empty.

출력

Output a single integer, which is 1ドル$ if it is possible for Carl to get from the starting location to the ending location, and 0ドル$ otherwise.

제한

예제 입력 1

4 5
1 1
4 5
00111
10100
10111
10000

예제 출력 1

1

예제 입력 2

3 3
1 1
3 3
001
001
110

예제 출력 2

0

노트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2025 D번

University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 1 D번

  • 문제를 만든 사람: Nick Wu
(追記) (追記ここまで)

출처

대학교 대회

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

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