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.