AtCoder Grand Contest 061
C
First Come First Serve
AtCoder
⌀ 2697
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ customers named $1,\ldots,N$ visiting a shop. Customer $i$ arrives at time $A_i$ and leaves at time $B_i$. The queue order is first in-first out, so $A_i$ are increasing, and $B_i$ are increasing. Additionally, all $A_i$ and $B_i$ 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 $998\,244\,353$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5 \cdot 10^5$
  • $1 \leq A_i < B_i \leq 2N$
  • $A_i < A_{i + 1}$ ($1 \leq i \leq N - 1$)
  • $B_i < B_{i + 1}$ ($1 \leq i \leq N - 1$)
  • $A_i \neq B_j$ ($i \neq j$)
  • All values in the input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 B_1
\vdots
A_N B_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3
1 3
2 5
4 6
Output #1
3
The possible orders are $(1, 2, 3)$, $(2, 1, 3)$, $(1, 3, 2)$.
Input #2
4
1 2
3 4
5 6
7 8
Output #2
1
The only possible order is $(1, 2, 3, 4)$.
题目信息
题号
agc061_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。