|
||||||||||
Intersection is not allowed!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1082 Accepted Submission(s): 352 Problem Description There are K pieces on the chessboard. The size of the chessboard is N*N. The pieces are initially placed on the top cells of the board. A piece located on (r, c) can be moved by one cell right to (r, c + 1) or one cell down to (r+1, c). Your task is to count how many different ways to move all pieces to the given positions at the bottom of the board. Furthermore, the paths of the pieces mustn’t intersect each other. Input The first line of input contains an integer T-the number of test cases. Each test case begins with a line containing two integers-N(1<=N<=100000) and K(1<=K<=100) representing the size of the chessboard and the number of pieces respectively. The second line contains K integers: 1<=a1<a2< …<aK<=N representing the initial positions of the pieces. That is, the pieces are located at (1, a1), (1, a2), …, (1, aK). Next line contains K integers: 1<=b1<b2<…<bK<=N representing the final positions of the pieces. This means the pieces should be moved to (N, b1), (N, b2), …, (N, bK). Output Print consecutive T lines, each of which represents the number of different ways modulo 1000000007. Sample Input
Sample Output
Author 金策工业综合大学(DPRK) Source | ||||||||||
|