QOJ.ac

QOJ

実行時間制限: 1.5 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#15302. チョコレートの分割

統計

Little L はサイズ $L \times W \times H$ のチョコレートを 1 つ持っています。チョコレートの内部には $n$ 個のアーモンドがあり、$i$ 番目のアーモンドは単位立方体 $[x_i - 1, x_i] \times [y_i - 1, y_i] \times [z_i - 1, z_i]$ の中心に位置しています。どの 2 つのアーモンドも同じ位置を占めることはありません。

今、Little L はこのチョコレートをいくつかのより小さなピースに切り分けたいと考えています。具体的には、3 つの次元に沿ってそれぞれ $p, q, r$ 回の切断を行いたいと考えています。各切断は整数座標に沿って行う必要があり、同じ次元の同じ座標で 2 回切断することはできず、またチョコレートの端(すなわち、座標 $0$ または $L, W, H$)で切断することもできません。

形式的には、$x$ 方向の座標 $k$ ($0 < k < L$) における切断とは、平面 $x = k$ に沿ってチョコレートを切断することを意味します。$y$ 方向および $z$ 方向についても同様です。

さらに、切断後に得られる $(p + 1)(q + 1)(r + 1)$ 個のチョコレートピースについて、Little L は各ピースに同じ個数のアーモンドが含まれることを望んでいます。Little L は、この条件を満たす本質的に異なる切断方法が何通りあるかを知りたいです。2 つの切断方法は、ある次元のある位置が存在して、1 つ目の方法ではその位置で切断し、2 つ目の方法では切断しない場合に異なるとみなされます。結果を $10^9 + 7$ で割った余りを出力してください。

入力

各テストケースの 1 行目には、チョコレートのサイズを表す 3 つの整数 $L, W, H$ ($1 \le L, W, H \le 10^9$) が与えられます。

2 行目には、$x$、$y$、$z$ 方向における切断回数をそれぞれ表す 3 つの整数 $p, q, r$ ($0 \le p, q, r \le 10^6$) が与えられます。

3 行目には、アーモンドの個数を表す整数 $n$ ($1 \le n \le 10^6$) が与えられます。

続く $n$ 行には、それぞれアーモンドの位置を表す 3 つの整数 $x_i, y_i, z_i$ ($1 \le x_i \le L, 1 \le y_i \le W, 1 \le z_i \le H$) が与えられます。すべての三つ組 $(x_i, y_i, z_i)$ が互いに異なることが保証されます。

出力

結果を $10^9 + 7$ で割った余りを表す整数を 1 行に出力してください。

入出力例

入力 1

4 4 1
1 1 0
4
1 2 1
2 4 1
3 1 1
4 3 1

出力 1

1

入力 2

3 3 3
1 1 1
3
1 1 1
2 2 2
3 3 3

出力 2

0

入力 3

9 9 9
1 1 1
8
1 1 2
2 2 8
1 9 1
2 8 9
8 2 1
9 2 9
9 8 1
8 9 7

出力 3

180

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.