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

32614번 - Gridlock 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 (추가 시간 없음) 1024 MB94457.143%

문제

The Foolish Puzzle Company posted an advertisement showcasing a new puzzle along with a very inefficient gameplay. Being taunted by the "99.99% cant solve these puzle" caption, you decided to download this puzzle. After wasting a good amount of time, you notice that the puzzles become larger and you are not having any kind of fun. You then decide to write a program to automatically solve the levels of this puzzle and skip the levels that are impossible.

A level of the puzzle gives you a rectangular grid with blocks. Each block contains an arrow that points in one of the cardinal directions (up, down, left, right). You can take out a block by sliding it in the direction that it points to. When sliding a block, you must slide it all the way out of the grid. You cannot slide it partially, slide another block, and go back to the same block to slide it out.

Given a grid, find a way to remove all the blocks, or state that it is impossible to take out all blocks.

입력

The input consists of:

  • One line with two integers $h$ and $w$ (1ドル\leq h, w\leq 2000$), the number of rows and the number of columns of the grid.
  • $h$ lines that contain strings of length $w$ consisting of the characters "<", "^", ">", and "v", each character representing the direction written on the block.

출력

If it is possible to solve the grid, print $h \cdot w$ pairs of numbers $y$ and $x$ (1ドル \leq y,x \leq n$), each pair representing a block that you take out from the grid, ordered from the first one to the last one. The two numbers in each pair represent the row and the column of the corresponding block, respectively.

If it is impossible to solve the grid, output "impossible".

If there are multiple valid solutions, you may output any one of them.

제한

예제 입력 1

2 2
>v
^<

예제 출력 1

impossible

예제 입력 2

3 3
<<<
<^<
>>^

예제 출력 2

1 1
2 1
1 2
1 3
2 2
2 3
3 3
3 2
3 1

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2023 G번

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

출처

대학교 대회

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

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