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 n mercenaries for hire, and the army should consist of some subset of them.
The i-th mercenary can be chosen if the resulting number of chosen mercenaries is not less than li (otherwise he deems the quest to be doomed) and not greater than ri (he doesn't want to share the trophies with too many other mercenaries). Furthermore, m 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] 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 998244353.
波利卡普正在玩一款(又一款!)策略类电脑游戏。在这款游戏中,他率领一支雇佣兵军队。
波利卡普希望为一次任务集结他的军队。目前有 n 名可雇佣的雇佣兵,而军队应由其中某个子集构成。
第 i 名雇佣兵可以被选中,当且仅当最终被选中的雇佣兵总数不小于 li(否则他认为该任务注定失败),且不大于 ri(他不愿与过多其他雇佣兵分享战利品)。此外,还有 m 对雇佣兵彼此憎恨,不能同时被选入同一支任务队伍。
波利卡普需要考虑多少个非空子集?换言之,请计算满足如下条件的非空雇佣兵子集的数目:对子集中每个被选中的雇佣兵 i,该子集的大小均属于区间 [li,ri];且子集中不存在一对彼此憎恨的雇佣兵。
答案可能很大,请对 998244353 取模。
输入格式
The first line contains two integers n and m (1≤n≤3⋅105, 0≤m≤min(20,2n(n−1))) — the number of mercenaries and the number of pairs of mercenaries that hate each other.
Then n lines follow, the i-th of them contains two integers li and ri (1≤li≤ri≤n).
Then m lines follow, the i-th of them contains two integers ai and bi (1≤ai<bi≤n) denoting that the mercenaries ai and bi hate each other. There are no two equal pairs in this list.
第一行包含两个整数 n 和 m(1≤n≤3⋅105,0≤m≤min(20,2n(n−1)))—— 分别表示雇佣兵人数以及相互憎恨的雇佣兵对数。
接下来 n 行,其中第 i 行包含两个整数 li 和 ri(1≤li≤ri≤n)。
接下来 m 行,其中第 i 行包含两个整数 ai 和 bi(1≤ai<bi≤n),表示雇佣兵 ai 和 bi 相互憎恨。该列表中不存在重复的数对。
输出格式
Print one integer — the number of non-empty subsets meeting the constraints, taken modulo 998244353.
输出一个整数——满足约束条件的非空子集的数量,对 998244353 取模。
输入输出样例
输入#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测评打分。不知道怎么写?