AT_arc226_a.Meeting Division

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are NN meetings numbered 1,2,…,N1,2,\dots,N. Meeting ii starts at time SiS_i and ends at time TiT_i.

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 ii and jj only if Ti≤SjT_i \le S_j or Tj≤SiT_j \le S_i.

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

有 NN 场会议,编号为 1,2,…,N1,2,\dots,N。第 ii 场会议在时刻 SiS_i 开始,在时刻 TiT_i 结束。

高桥和青木将为每场会议恰好指定其中一人作为负责人。同一人不能同时负责两场在时间上存在正长度重叠的会议。更准确地说,同一人可以同时负责会议 ii 和会议 jj,当且仅当 Ti≤SjT_i \le S_j 或 Tj≤SiT_j \le S_i。

求满足上述条件的负责人分配方案数(对 998244353998244353 取模)。

输入格式

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

NN
S1S_1 T1T_1
S2S_2 T2T_2
⋮\vdots
SNS_N TNT_N

输入从标准输入中按以下格式给出:

NN
S1S_1 T1T_1
S2S_2 T2T_2
⋮\vdots
SNS_N TNT_N

输出格式

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

输出满足条件的负责人分配方案数对 998244353998244353 取模的结果。

输入输出样例

  • 输入#1

    3
    1 3
    2 4
    5 6

    输出#1

    4
  • 输入#2

    3
    1 4
    2 5
    3 6

    输出#2

    0

说明/提示

Sample 1 Explanation:
The following four assignments satisfy the conditions:

  • Takahashi is in charge of meetings 1,31,3, and Aoki is in charge of meeting 22.
  • Takahashi is in charge of meeting 11, and Aoki is in charge of meetings 2,32,3.
  • Takahashi is in charge of meetings 2,32,3, and Aoki is in charge of meeting 11.
  • Takahashi is in charge of meeting 22, and Aoki is in charge of meetings 1,31,3.

Sample 2 Explanation:
Zero assignments satisfy the conditions.

Constraints

  • 1≤N≤3×1051 \le N \le 3 \times 10^5
  • 1≤Si<Ti≤2N1 \le S_i < T_i \le 2N
  • S1,T1,S2,T2,…,SN,TNS_1,T_1,S_2,T_2,\dots,S_N,T_N are all different.
  • All input values are integers.

样例 1 解释:
以下四种分配方案满足条件:

  • 高桥负责会议 1,31,3,青木负责会议 22。
  • 高桥负责会议 11,青木负责会议 2,32,3。
  • 高桥负责会议 2,32,3,青木负责会议 11。
  • 高桥负责会议 22,青木负责会议 1,31,3。

样例 2 解释:
不存在满足条件的分配方案。

约束条件

  • 1≤N≤3×1051 \le N \le 3 \times 10^5
  • 1≤Si<Ti≤2N1 \le S_i < T_i \le 2N
  • S1,T1,S2,T2,…,SN,TNS_1,T_1,S_2,T_2,\dots,S_N,T_N 互不相同。
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页