#P14006. 「florr IO Round 1」命运游戏

    ID: 13380 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP洛谷原创组合数学洛谷月赛

「florr IO Round 1」命运游戏

Description

There are nn nodes forming a ring. For any positive integer i[1,n]i \in [1, n], there is a bidirectional edge between ii and (imodn)+1(i \bmod n) + 1.

There are two pieces, one black and one white. The white piece starts at node xx, and the black piece starts at node yy. Each second, both pieces move simultaneously: the white piece moves along one edge in the direction the black piece moved in the previous second (if both pieces were on the same node in the previous second, the white piece does not move), while the black piece can choose to move one edge in either direction or stay in place.

You are required to find the number of possible ways in which the two pieces never occupy the same node at the same time within kk seconds, modulo 998244353998244353.

In this problem, nn is odd.

Two ways are considered different if and only if there exists a moment when the movement direction of at least one piece differs between the two ways.

Input Format

Four integers n,x,y,kn, x, y, k.

Output Format

A single integer representing the answer.

5 1 4 3
4
7 1 5 6
28
1145 141 919 810
783109298

Hint

Sample Explanation

For sample 1:

As shown in the figure, the white piece is at node 11, and the black piece is at node 44.

One possible way is:

  • In the first second, the white piece moves to node 55, and the black piece moves to node 33.
  • In the second second, the white piece moves to node 44, and the black piece stays in place.
  • In the third second, the white piece moves to node 33, and the black piece moves to node 22.

By enumerating all possibilities, it is easy to find that there are only four valid ways.

Data Range

This problem uses bundled testing.

Subtask ID Special Property Subtask\tt Subtask Score
00 k3k \leq 3 3030
11 n,k500n, k \leq 500
22 None 4040

For all data, 1n,k7×103,1x,yn1 \leq n, k \leq 7 \times 10^3, 1 \leq x, y \leq n.

Translated by ChatGPT 4.1