同步操作将从 doocs/leetcode 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
There is an 8 x 8
chessboard containing n
pieces (rooks, queens, or bishops). You are given a string array pieces
of length n
, where pieces[i]
describes the type (rook, queen, or bishop) of the ith
piece. In addition, you are given a 2D integer array positions
also of length n
, where positions[i] = [ri, ci]
indicates that the ith
piece is currently at the 1-based coordinate (ri, ci)
on the chessboard.
When making a move for a piece, you choose a destination square that the piece will travel toward and stop on.
(r, c)
to the direction of (r+1, c)
, (r-1, c)
, (r, c+1)
, or (r, c-1)
.(r, c)
to the direction of (r+1, c)
, (r-1, c)
, (r, c+1)
, (r, c-1)
, (r+1, c+1)
, (r+1, c-1)
, (r-1, c+1)
, (r-1, c-1)
.(r, c)
to the direction of (r+1, c+1)
, (r+1, c-1)
, (r-1, c+1)
, (r-1, c-1)
.You must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece will instantaneously travel one square towards their destination if they are not already at it. All pieces start traveling at the 0th
second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.
Return the number of valid move combinations.
Notes:
Example 1:
Input: pieces = ["rook"], positions = [[1,1]] Output: 15 Explanation: The image above shows the possible squares the piece can move to.
Example 2:
Input: pieces = ["queen"], positions = [[1,1]] Output: 22 Explanation: The image above shows the possible squares the piece can move to.
Example 3:
Input: pieces = ["bishop"], positions = [[4,3]] Output: 12 Explanation: The image above shows the possible squares the piece can move to.
Constraints:
n == pieces.length
n == positions.length
1 <= n <= 4
pieces
only contains the strings "rook"
, "queen"
, and "bishop"
.1 <= xi, yi <= 8
positions[i]
is distinct.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。