Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

整数 $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)$ に置かれた明かりは、以下の 2 つの条件をともに満たすすべての白いマスを照らします:

  • マス $(i, j)$ と同じ行または同じ列にある。
  • マス $(i, j)$ とそのマスの間に黒いマスが存在しない。

明かりの配置は以下の 2 つの条件を満たすとき、有効であるといいます:

  • すべての白いマスが少なくとも 1 つの明かりによって照らされている。
  • 明かりが置かれているどのマスも、他のどの明かりによっても照らされていない。

有効な明かりの配置の個数を $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$ 通りあります。図では、明かりが置かれたマスおよび明かりに照らされた白いマスが緑色で示されています。

problem_16233_1.png

条件を満たさない配置もあります:左の例ではどの明かりにも照らされていない白いマスが少なくとも 1 つ存在し、右の例では明かりが置かれた白いマスが別の明かりによって照らされています。これらはどちらも無効です。

problem_16233_2.png

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.