| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 81 | 42 | 33 | 52.381% |
Bessie has two arrays of length $N$ (1ドル \le N \le 500$). The $i$-th element of the first array is $a_i$ (1ドル \le a_i \le 10^6$) and the $i$-th element of the second array is $b_i$ (1ドル \le b_i \le 10^6$).
Bessie wants to split both arrays into non-empty subarrays such that the following is true.
Count how many ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 10ドル^9+7$. Two ways are considered different if the number of subarrays are different or if some element belongs in a different subarray.
The first line contains $N$.
The next line contains $a_1,a_2,...,a_N$.
The next line contains $b_1,b_2,...,b_N$.
Output the number of ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 10ドル^9+7$.
2 1 2 2 2
2
The two valid ways are:
3 1 3 2 2 2 2
3
The three valid ways are:
5 2 5 1 3 2 2 1 5 2 2
1
The only valid way is to split the first array into $[2],[5,1,3],[2]$ and the second array into $[2],[1,5],[2,2]$.
7 3 5 2 3 4 4 1 5 3 5 3 3 4 1
140