CF1575K.Knitting Batik

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Mr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid aa with size n×mn \times m. There are kk colors, and each cell in the grid can be one of the kk colors.

Define a sub-rectangle as an ordered pair of two cells ((x1,y1),(x2,y2))((x_1, y_1), (x_2, y_2)), denoting the top-left cell and bottom-right cell (inclusively) of a sub-rectangle in aa. Two sub-rectangles ((x1,y1),(x2,y2))((x_1, y_1), (x_2, y_2)) and ((x3,y3),(x4,y4))((x_3, y_3), (x_4, y_4)) have the same pattern if and only if the following holds:

  • they have the same width (x2−x1=x4−x3x_2 - x_1 = x_4 - x_3);
  • they have the same height (y2−y1=y4−y3y_2 - y_1 = y_4 - y_3);
  • for every pair (i,j)(i, j) where 0≤i≤x2−x10 \leq i \leq x_2 - x_1 and 0≤j≤y2−y10 \leq j \leq y_2 - y_1, the color of cells (x1+i,y1+j)(x_1 + i, y_1 + j) and (x3+i,y3+j)(x_3 + i, y_3 + j) are equal.

Count the number of possible batik color combinations, such that the subrectangles ((ax,ay),(ax+r−1,ay+c−1))((a_x, a_y),(a_x + r - 1, a_y + c - 1)) and ((bx,by),(bx+r−1,by+c−1))((b_x, b_y),(b_x + r - 1, b_y + c - 1)) have the same pattern.

Output the answer modulo 109+710^9 + 7.

Chanek 先生想制作一块蜡染布,这是一种源自印度尼西亚的传统织物。该织物构成一个大小为 n×mn \times m 的网格 aa。共有 kk 种颜色,网格中每个单元格可染其中任意一种颜色。

定义一个子矩形为一对有序单元格 ((x1,y1),(x2,y2))((x_1, y_1), (x_2, y_2)),表示网格 aa 中一个子矩形的左上角单元格与右下角单元格(含边界)。两个子矩形 ((x1,y1),(x2,y2))((x_1, y_1), (x_2, y_2)) 和 ((x3,y3),(x4,y4))((x_3, y_3), (x_4, y_4)) 具有相同图案,当且仅当满足以下条件:

  • 它们具有相同的宽度(即 x2−x1=x4−x3x_2 - x_1 = x_4 - x_3);
  • 它们具有相同的高度(即 y2−y1=y4−y3y_2 - y_1 = y_4 - y_3);
  • 对于所有满足 0≤i≤x2−x10 \leq i \leq x_2 - x_1 且 0≤j≤y2−y10 \leq j \leq y_2 - y_1 的数对 (i,j)(i, j),单元格 (x1+i,y1+j)(x_1 + i, y_1 + j) 与 (x3+i,y3+j)(x_3 + i, y_3 + j) 的颜色均相同。

请计算满足如下条件的蜡染布染色方案总数:子矩形 ((ax,ay),(ax+r−1,ay+c−1))((a_x, a_y),(a_x + r - 1, a_y + c - 1)) 与 ((bx,by),(bx+r−1,by+c−1))((b_x, b_y),(b_x + r - 1, b_y + c - 1)) 具有相同图案。

输出答案对 109+710^9 + 7 取模的结果。

输入格式

The first line contains five integers nn, mm, kk, rr, and cc (1≤n,m≤1091 \leq n, m \leq 10^9, 1≤k≤1091 \leq k \leq 10^9, 1≤r≤min⁡(106,n)1 \leq r \leq \min(10^6, n), 1≤c≤min⁡(106,m)1 \leq c \leq \min(10^6, m)) — the size of the batik, the number of colors, and size of the sub-rectangle.

The second line contains four integers axa_x, aya_y, bxb_x, and byb_y (1≤ax,bx≤n1 \leq a_x, b_x \leq n, 1≤ay,by≤m1 \leq a_y, b_y \leq m) — the top-left corners of the first and second sub-rectangle. Both of the sub-rectangles given are inside the grid (1≤ax+r−11 \leq a_x + r - 1, bx+r−1≤nb_x + r - 1 \leq n, 1≤ay+c−11 \leq a_y + c - 1, by+c−1≤mb_y + c - 1 \leq m).

第一行包含五个整数 nn、mm、kk、rr 和 cc(1≤n,m≤1091 \leq n, m \leq 10^9,1≤k≤1091 \leq k \leq 10^9,1≤r≤min⁡(106,n)1 \leq r \leq \min(10^6, n),1≤c≤min⁡(106,m)1 \leq c \leq \min(10^6, m))——分别表示蜡染布的尺寸、颜色数量以及子矩形的尺寸。

第二行包含四个整数 axa_x、aya_y、bxb_x 和 byb_y(1≤ax,bx≤n1 \leq a_x, b_x \leq n,1≤ay,by≤m1 \leq a_y, b_y \leq m)——分别为第一个和第二个子矩形的左上角坐标。所给的两个子矩形均位于网格内部(即满足 1≤ax+r−11 \leq a_x + r - 1,bx+r−1≤nb_x + r - 1 \leq n,1≤ay+c−11 \leq a_y + c - 1,by+c−1≤mb_y + c - 1 \leq m)。

输出格式

Output an integer denoting the number of possible batik color combinations modulo 109+710^9 + 7.

输出一个整数,表示可能的蜡染颜色组合数对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    3 3 2 2 2
    1 1 2 2

    输出#1

    32
  • 输入#2

    4 5 170845 2 2
    1 4 3 1

    输出#2

    756680455

说明/提示

The following are all 3232 possible color combinations in the first example.

以下是第一个示例中的全部 3232 种颜色组合。

输入解题思路,AI测评打分。不知道怎么写?

首页