QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#16233. Akari Counting

Estadísticas

给你整数 $H, W, A, B, C, D$。

有一个 $H$ 行 $W$ 列的网格。从上往下数第 $i$ 行、从左往右数第 $j$ 列的格子称为格子 $(i, j)$。

每个格子都被涂成白色或黑色。格子 $(i, j)$ 是黑色的当且仅当 $A \le i \le B$ 且 $C \le j \le D$;否则它是白色的。

你在该网格的一些白色格子中放置灯泡。放置在白色格子 $(i, j)$ 上的灯泡会照亮所有满足以下两个条件的白色格子:

  • 它们与格子 $(i, j)$ 处于同一行或同一列。
  • 格子 $(i, j)$ 与该格子之间没有黑色格子。

如果一个灯泡放置方案满足以下两个条件,则称其为合法的

  • 每个白色格子都至少被一盏灯照亮。
  • 任何放置了灯泡的格子都不会被其他任何灯泡照亮。

求合法灯泡放置方案的数量,模 $998244353$ 的结果。

输入格式

输入按以下格式给出:

H W A B C D
  • 所有输入值均为整数。
  • $1 \le A \le B \le H \le 5 \times 10^5$
  • $1 \le C \le D \le W \le 5 \times 10^5$
  • $(A, B) \ne (1, H)$
  • $(C, D) \ne (1, W)$

输出格式

输出答案。

样例

输入样例 1

3 3 2 2 2 2

输出样例 1

7

输入样例 2

2 3 1 1 1 2

输出样例 2

3

输入样例 3

500000 500000 100000 200000 100000 250000

输出样例 3

360665510

说明

在第一个样例中,恰好有 7 种合法的灯泡放置方案。放置了灯泡的格子以及被灯泡照亮的白色格子在下图中用绿色表示。

有些放置方案不满足条件:在左侧的情况下,存在至少一个未被任何灯泡照亮的白色格子;在右侧的情况下,有一个放置了灯泡的格子被另一个灯泡照亮。这两种情况都是不合法的。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.