F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

permutation 2

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1084    Accepted Submission(s): 629


Problem Description
You are given three positive integers $N, x, y$.
Please calculate how many permutations of $1 \sim N$ satisfies the following conditions (We denote the $i$-th number of a permutation by $p_i$):

1. $p_1 = x$

2. $p_N = y$

3. for all $1 \le i <N$, $|p_i - p_{i+1}| \le 2$
 

Input
The first line contains one integer $T$ denoting the number of tests.

For each test, there is one line containing three integers $N, x, y$.

* $1 \le T \le 5000$

* $2 \le N \le 10^5$

* $1 \le x < y \le N$
 

Output
For each test, output one integer in a single line indicating the answer modulo $998244353$.
 

Sample Input
3 4 1 4 4 2 4 100000 514 51144
 

Sample Output
2 1 253604680
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-21 22:46:59, Gzip enabled