QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#116. 帐篷

统计

JOI-kun 经营着一个露营地。这个露营地被划分为一个 $H$ 行 $W$ 列的矩形网格。行平行于东西方向,列平行于南北方向。从北往南数第 $i$ 行、从东往西数第 $j$ 列的区域被称为区域 $(i, j)$。

JOI-kun 打算在一些区域搭建帐篷。每个帐篷必须恰好占据一个区域。任意两个帐篷不能占据同一个区域。

每个帐篷都有一个朝向北、南、东或西的入口。露营地中搭建的帐篷的入口朝向必须满足以下条件:

  • 如果区域 $(i_1, j)$ 和 $(i_2, j)$ ($1 \le i_1 < i_2 \le H, 1 \le j \le W$) 都被帐篷占据,那么区域 $(i_1, j)$ 中帐篷的入口必须朝南,区域 $(i_2, j)$ 中帐篷的入口必须朝北。
  • 如果区域 $(i, j_1)$ 和 $(i, j_2)$ ($1 \le i \le H, 1 \le j_1 < j_2 \le W$) 都被帐篷占据,那么区域 $(i, j_1)$ 中帐篷的入口必须朝东,区域 $(i, j_2)$ 中帐篷的入口必须朝西。

JOI-kun 对在露营地中搭建至少一个帐篷的方法数产生了兴趣。如果存在一个区域,其帐篷的状态(是否有帐篷,或者帐篷入口的朝向)不同,则认为这是两种不同的搭建方式。

编写一个程序,计算满足题目描述条件的、至少搭建一个帐篷的方法数,并输出其除以 $1\,000\,000\,007$ 的余数。

输入格式

从标准输入读取以下数据:

  • 第一行包含两个整数 $H$ 和 $W$。这意味着 JOI-kun 经营的露营地被划分为 $H$ 行 $W$ 列。

输出格式

输出一行到标准输出。该行应包含满足题目描述条件的、至少搭建一个帐篷的方法数,除以 $1\,000\,000\,007$ 的余数。

数据范围

所有输入数据满足以下条件:

  • $1 \le H \le 3\,000$
  • $1 \le W \le 3\,000$

子任务

共有 2 个子任务。各子任务的分值和附加限制如下:

子任务 1 [48 分]

  • $1 \le H \le 300$
  • $1 \le W \le 300$

子任务 2 [52 分]

  • 无附加限制。

样例

样例输入 1

1 2

样例输出 1

9

说明

用字符 'E'、'W'、'S'、'N' 分别表示入口朝向东、西、南、北的帐篷。共有九种搭建帐篷的方式,如下图所示:

样例输入 2

4 3

样例输出 2

3252

样例输入 3

100 100

样例输出 3

561068619

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.