题库练习 Valid Bitonic Permutations
← 上一题 下一题 →

A15490 | Valid Bitonic Permutations

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given five integers $n$ , $i$ , $j$ , $x$ , and $y$ . Find the number of bitonic permutations $B$ , of the numbers $1$ to $n$ , such that $B_i=x$ , and $B_j=y$ . Since the answer can be large, compute it modulo $10^9+7$ .

A bitonic permutation is a permutation of numbers, such that the elements of the permutation first increase till a certain index $k$ , $2 \le k \le n-1$ , and then decrease till the end. Refer to notes for further clarification.

输入格式

Each test contains multiple test cases. The first line contains a single integer $t$ ( $1 \le t \le 100$ ) — the number of test cases. The description of test cases follows.

The only line of each test case contains five integers, $n$ , $i$ , $j$ , $x$ , and $y$ ( $3 \le n \le 100$ and $1 \le i,j,x,y \le n$ ). It is guaranteed that $i < j$ and $x \ne y$ .

输出格式

For each test case, output a single line containing the number of bitonic permutations satisfying the above conditions modulo $10^9+7$ .

输入输出样例

输入 #1
7
3 1 3 2 3
3 2 3 3 2
4 3 4 3 1
5 2 5 2 4
5 3 4 5 4
9 3 7 8 6
20 6 15 8 17
输出 #1
0
1
1
1
3
0
4788
C++ 编辑器
输入
输出