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

20574번 - General Knight 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB244857535.714%

문제

For the uninitiated, chess is a board game is played on a grid of 8ドル \times 8$ squares. The rows are numbered 1ドル$ to 8ドル$ with row 1ドル$ at the bottom and columns are labeled with lowercase $a$ to $h$. The label of a square is its column, then its row. For example, valid square labels are $a1$ and $e5$.

In chess, a piece threatens a square on the board if the piece can move to that square in one move. The knight is one of the more fearsome chess pieces, as it moves differently from the other pieces. In a single move, a knight can move two rows and one column or one column and two rows. The image below shows the squares a standard chess knight threatens if it starts in square $e5$.

The standard chess knight is a $(2, 1)$-knight. The more general version is an $(a, b)$-knight, which in one move can move either $a$ rows and $b$ columns, or $b$ rows and $a$ columns. Citizens of the chessboard are concerned, as they don't know how powerful these new knights are. Given an $(a, b)$-knight and its starting square, which squares does it threaten?

입력

Input consists of two lines. The first line has two space-separated integers $a$ and $b,ドル the properties of the knight. It is guaranteed that 0ドル \leq a, b < 8$ and $\max(a, b) > 0$. The second line contains the starting location of the $(a, b)$-knight. This is given in standard chess notation as described above.

출력

First, output an integer $k,ドル the number of squares the knight can reach. On the second line, output $k$ space separated strings, the positions the knight can move to in exactly one move. Sort these positions in increasing column order, breaking ties by increasing row.

제한

예제 입력 1

4 5
a1

예제 출력 1

2
e6 f5

예제 입력 2

2 1
e5

예제 출력 2

8
c4 c6 d3 d7 f3 f7 g4 g6

힌트

출처

University > UT Invitational Programming Contest > UT Invitational Programming Contest 2019 J번

  • 문제를 만든 사람: Arnav Sastry, Ethan Arnold
(追記) (追記ここまで)

출처

대학교 대회

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

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