ユニークビジョンプログラミングコンテスト2026 夏(AtCoder Regular Contest 226)
A
会议分配
Meeting Division
AtCoder
⌀ 313
原题
←B →

会议分配AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There are $N$ meetings numbered $1,2,\dots,N$. Meeting $i$ starts at time $S_i$ and ends at time $T_i$.

有 $N$ 场会议,编号为 $1,2,\dots,N$。会议 $i$ 在时刻 $S_i$ 开始,在时刻 $T_i$ 结束。AI (CI翻译)

Takahashi and Aoki are going to assign exactly one of themselves to each meeting as the person in charge. The same person cannot be in charge of two meetings that overlap for a positive length of time. More formally, the same person can be in charge of meetings $i$ and $j$ only if $T_i \le S_j$ or $T_j \le S_i$.

高桥和青木将为每场会议指定一人负责。对于任意两场有正时长重叠的会议,不能由同一人负责。更正式地说,只有当 $T_i \le S_j$ 或 $T_j \le S_i$ 时,同一个人才可以负责会议 $i$ 和会议 $j$。AI (CI翻译)

Find the number, modulo $998244353$, of ways to assign the people in charge that satisfy the conditions.

请计算满足条件的负责人分配方案数,并对 $998244353$ 取模。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \le N \le 3 \times 10^5$
  • $1 \le S_i < T_i \le 2N$
  • $S_1,T_1,S_2,T_2,\dots,S_N,T_N$ are all different.
  • All input values are integers.
  • $1 \le N \le 3 \times 10^5$
  • $1 \le S_i < T_i \le 2N$
  • $S_1,T_1,S_2,T_2,\dots,S_N,T_N$ 互不相同。
  • 输入的所有数值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N
S_1 T_1
S_2 T_2
\vdots
S_N T_N

N
S_1 T_1
S_2 T_2
\vdots
S_N T_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the number, modulo $998244353$, of ways to assign the people in charge that satisfy the conditions.

输出满足条件的负责人分配方案数,并对 $998244353$ 取模。AI (CI翻译)

样例

Input #1
3
1 3
2 4
5 6
Output #1
4
The following four assignments satisfy the conditions: - Takahashi is in charge of meetings $1,3$, and Aoki is in charge of meeting $2$. - Takahashi is in charge of meeting $1$, and Aoki is in charge of meetings $2,3$. - Takahashi is in charge of meetings $2,3$, and Aoki is in charge of meeting $1$. - Takahashi is in charge of meeting $2$, and Aoki is in charge of meetings $1,3$.
Input #2
3
1 4
2 5
3 6
Output #2
0
Zero assignments satisfy the conditions.
题目信息

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