Codeforces 第 940 轮&& CodeCraft-23 (Div. 2) [C]How Does the Rook Move题解

题目详情

C.How Does the Rook Move?

You are given an 𝑛×𝑛 chessboard where you and the computer take turns alternatingly to place white rooks & black rooks on the board respectively. While placing rooks, you have to ensure that no two rooks attack each other. Two rooks attack each other if they share the same row or column regardless of color.

A valid move is placing a rook on a position (𝑟, 𝑐) such that it doesn't attack any other rook.

You start first, and when you make a valid move in your turn, placing a white rook at position (𝑟, 𝑐), the computer will mirror you and place a black rook at position (𝑐, 𝑟) in its turn. If 𝑟=𝑐, then the computer can't mirror your move, and skips its turn.

You have already played 𝑘 moves with the computer (the computer tries to mirror these moves too), and you must continue playing the game until there are no valid moves remaining. How many different final configurations are possible when you continue the game after the 𝑘 moves? It is guaranteed that the 𝑘 moves and the implied computer moves are valid. Since the answer may be large, print it modulo 10^{9} + 7.

Two configurations are considered different if there exists a coordinate (𝑟, 𝑐) which has a rook in one configuration, but not in the other or the color of the rook on the coordinate is different.

Input

The first line contains a single integer 𝑡 (1\leq t\leq 10^{4}) — the number of test cases.

The first line of each test case contains two integers 𝑛𝑛 and 𝑘 (1 \leq n \leq 3 * 10^{5},0 \leq k \leq n) — the size of the chessboard and the number of moves you have

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值