QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#14426. 網格問題

Statistics

Yotsugi 正在玩一個高度為 $h$、寬度為 $w$ 的網格 $A$,該網格最初全部填滿零,她按某種順序對其執行以下 2 種操作:

  • 選擇值 $i, j$($0 \le i \le h - 1, 0 \le j \le w - 1$)以及符號 $+$ 或 $-$,並將 $A_{i,j}, A_{i,j+1}, A_{i+1,j}, A_{i+1,j+1}$ 的值相應地修改為 $A_{i,j} \pm 2, A_{i,j+1} \pm 1, A_{i+1,j} \pm 1, A_{i+1,j+1} \pm 2$,其中 $\pm$ 被替換為所選的符號。在這裡,Yotsugi 認為 $A_{h,j}$ 等價於 $A_{0,j}$,$A_{i,w}$ 等價於 $A_{i,0}$。換句話說,她將網格視為一個環面(torus)。
  • 選擇值 $i, j$($0 \le i \le h - 1, 0 \le j \le w - 1$)以及符號 $+$ 或 $-$,並將 $A_{i,j}, A_{i,j+1}, A_{i,j+2}, A_{i+1,j}, A_{i+1,j+1}, A_{i+1,j+2}, A_{i+2,j}, A_{i+2,j+1}, A_{i+2,j+2}$ 的值相應地修改為 $A_{i,j} \pm 2, A_{i,j+1} \pm 5, A_{i,j+2} \pm 2, A_{i+1,j} \pm 5, A_{i+1,j+1} \pm 5, A_{i+1,j+2} \pm 5, A_{i+2,j} \pm 2, A_{i+2,j+1} \pm 5, A_{i+2,j+2} \pm 2$,其中 $\pm$ 被替換為所選的符號。與前一個操作相同,Yotsugi 將網格視為一個環面。

為了更容易理解這些操作,請參考說明部分。

隔天,網格被噴火蛞蝓吃掉了,現在 Yotsugi 想知道,如果她在完成所有操作後,所有值 $A_{i,j}$ 都位於 $[0, k]$ 內,她可能得到多少種不同的網格。注意,當 Yotsugi 執行操作時,值 $A_{i,j}$ 可以是負數或超過 $k$。由於答案可能很大,請幫她求出答案對 $10^9 + 9$ 取模後的結果。

輸入格式

第一行包含 3 個整數 $h, w, k$($3 \le h, w \le 1\,000$,$1 \le k \le 10^9$)—— 網格的大小以及網格中可能的最大值。

輸出格式

輸出問題的答案對 $10^9 + 9$ 取模後的結果。

範例

輸入格式 1

3 3 1

輸出格式 1

2

輸入格式 2

4 4 52

輸出格式 2

972950693

輸入格式 3

7 10 123

輸出格式 3

93519598

說明

例如,如果我們有一個 $4 \times 4$ 的矩陣,我們可以按如下方式執行操作:

problem_14426_bdc5aaccf4f57ccf8e281b69a642fa5f.png

使用符號 $-$ 執行第一種操作。

problem_14426_c7868b974cacb61057c7998f75650c36.png

使用符號 $+$ 執行第二種操作。

problem_14426_bc6d6c6bdfd571cbf1363a33e2c0b200.png

使用符號 $+$ 執行第一種操作。

problem_14426_0aa751704d08e9f39b2346eade004eb7.png

使用符號 $+$ 執行第一種操作。

由於所有值都位於 $[0, 42]$ 內,因此這是第二個範例中要求你計數的矩陣之一。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#364EditorialOpen题解jianglyView

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.