atcoder#AGC061C. [AGC061C] First Come First Serve
[AGC061C] First Come First Serve
Score : points
Problem Statement
There are customers named visiting a shop. Customer arrives at time and leaves at time . The queue order is first in-first out, so are increasing, and are increasing. Additionally, all and are pairwise distinct.
At the entrance there's a list of visitors to put their names in. Each customer will write down their name next in the list exactly once, either when they arrive or when they leave. How many different orders of names can there be in the end? Find the count modulo .
Constraints
- ()
- ()
- ()
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 3
2 5
4 6
3
The possible orders are , , .
4
1 2
3 4
5 6
7 8
1
The only possible order is .