CF1400G.Mercenaries

省选/NOI-

通过率:0%

时间限制:7.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.

Polycarp wants to gather his army for a quest. There are nn mercenaries for hire, and the army should consist of some subset of them.

The ii-th mercenary can be chosen if the resulting number of chosen mercenaries is not less than lil_i (otherwise he deems the quest to be doomed) and not greater than rir_i (he doesn't want to share the trophies with too many other mercenaries). Furthermore, mm pairs of mercenaries hate each other and cannot be chosen for the same quest.

How many non-empty subsets does Polycarp need to consider? In other words, calculate the number of non-empty subsets of mercenaries such that the size of this subset belongs to [li,ri][l_i, r_i] for each chosen mercenary, and there are no two mercenaries in the subset that hate each other.

The answer may be large, so calculate it modulo 998244353998244353.

波利卡普正在玩一款(又一款!)策略类电脑游戏。在这款游戏中,他率领一支雇佣兵军队。

波利卡普希望为一次任务集结他的军队。目前有 nn 名可雇佣的雇佣兵,而军队应由其中某个子集构成。

第 ii 名雇佣兵可以被选中,当且仅当最终被选中的雇佣兵总数不小于 lil_i(否则他认为该任务注定失败),且不大于 rir_i(他不愿与过多其他雇佣兵分享战利品)。此外,还有 mm 对雇佣兵彼此憎恨,不能同时被选入同一支任务队伍。

波利卡普需要考虑多少个非空子集?换言之,请计算满足如下条件的非空雇佣兵子集的数目:对子集中每个被选中的雇佣兵 ii,该子集的大小均属于区间 [li,ri][l_i, r_i];且子集中不存在一对彼此憎恨的雇佣兵。

答案可能很大,请对 998244353998244353 取模。

输入格式

The first line contains two integers nn and mm (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5, 0≤m≤min⁡(20,n(n−1)2)0 \le m \le \min(20, \dfrac{n(n-1)}{2})) — the number of mercenaries and the number of pairs of mercenaries that hate each other.

Then nn lines follow, the ii-th of them contains two integers lil_i and rir_i (1≤li≤ri≤n1 \le l_i \le r_i \le n).

Then mm lines follow, the ii-th of them contains two integers aia_i and bib_i (1≤ai<bi≤n1 \le a_i \lt b_i \le n) denoting that the mercenaries aia_i and bib_i hate each other. There are no two equal pairs in this list.

第一行包含两个整数 nn 和 mm(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5,0≤m≤min⁡(20,n(n−1)2)0 \le m \le \min(20, \dfrac{n(n-1)}{2}))—— 分别表示雇佣兵人数以及相互憎恨的雇佣兵对数。

接下来 nn 行,其中第 ii 行包含两个整数 lil_i 和 rir_i(1≤li≤ri≤n1 \le l_i \le r_i \le n)。

接下来 mm 行,其中第 ii 行包含两个整数 aia_i 和 bib_i(1≤ai<bi≤n1 \le a_i \lt b_i \le n),表示雇佣兵 aia_i 和 bib_i 相互憎恨。该列表中不存在重复的数对。

输出格式

Print one integer — the number of non-empty subsets meeting the constraints, taken modulo 998244353998244353.

输出一个整数——满足约束条件的非空子集的数量,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    3 0
    1 1
    2 3
    1 3

    输出#1

    3
  • 输入#2

    3 1
    1 1
    2 3
    1 3
    2 3

    输出#2

    2

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

首页