CF2240B.AI Finds Nothing Here

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Milkcat2009 has a matrix aa with nn rows and mm columns consisting of integers 00 and 11. The rows are numbered from 11 to nn, and the columns are numbered from 11 to mm. The element in the ii-th row and jj-th column is denoted as ai,ja_{i,j}.

Milkcat2009's AI scans every single submatrix∗^{\text{∗}} of aa consisting of rr rows and cc columns. The AI considers the matrix clean if the bitwise XOR sum of elements in each such submatrix is equal to 00.

Formally, the matrix aa is valid if and only if for all 1≤i≤n−r+11 \le i \le n - r + 1 and 1≤j≤m−c+11 \le j \le m - c + 1: $$ \bigoplus_{x=i}^{i+r-1} \bigoplus_{y=j}^{j+c-1} a_{x,y} = 0 $$

where ⊕\oplus denotes summation with the bitwise XOR operation.

Your task is, given various sets of integers n,m,r,cn, m, r, c, to count the number of clean matrices of nn rows and mm columns with respect to scanning dimensions rr and cc. Since the answer can be very large, calculate it modulo 998 244 353998\,244\,353.

∗^{\text{∗}}A submatrix of a matrix is obtained by removing some rows (from the beginning and/or end) and/or columns (from the beginning and/or end) from the original matrix.

Milkcat2009 有一个由 00 和 11 组成的 nn 行 mm 列矩阵 aa。行编号从 11 到 nn,列编号从 11 到 mm。第 ii 行第 jj 列的元素记为 ai,ja_{i,j}。

Milkcat2009 的人工智能会扫描矩阵 aa 的每一个大小为 rr 行 cc 列的子矩阵∗^{\text{∗}}。若每个这样的子矩阵中所有元素的按位异或(XOR)和等于 00,则该人工智能认为该矩阵是“洁净的”。

形式化地,矩阵 aa 是有效的当且仅当对所有满足 1≤i≤n−r+11 \le i \le n - r + 1 和 1≤j≤m−c+11 \le j \le m - c + 1 的 i,ji, j,均有:

⨁x=ii+r−1⨁y=jj+c−1ax,y=0\bigoplus_{x=i}^{i+r-1} \bigoplus_{y=j}^{j+c-1} a_{x,y} = 0

其中 ⊕\oplus 表示按位异或运算。

你的任务是:对于给定的多组整数 n,m,r,cn, m, r, c,计算关于扫描尺寸 rr 和 cc 的 nn 行 mm 列洁净矩阵的个数。由于答案可能非常大,请对 998 244 353998\,244\,353 取模。

∗^{\text{∗}} 矩阵的一个子矩阵是通过从原矩阵的开头和/或结尾删除若干行和/或列而得到的。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

Each test case consists of a single line containing four integers n,m,r,cn, m, r, c (1≤r≤n≤1091 \le r \le n \le 10^9, 1≤c≤m≤1091 \le c \le m \le 10^9), representing the dimensions of the matrix and the dimensions of the scanning area, respectively.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例由一行组成,包含四个整数 n,m,r,cn, m, r, c(1≤r≤n≤1091 \le r \le n \le 10^9,1≤c≤m≤1091 \le c \le m \le 10^9),分别表示矩阵的维度和扫描区域的维度。

输出格式

For each test case, output a single integer representing the answer modulo 998 244 353998\,244\,353.

对于每个测试用例,输出一个整数,表示答案对 998 244 353998\,244\,353 取模的结果。

输入输出样例

  • 输入#1

    8
    1 1 1 1
    2 3 1 2
    2 5 2 2
    3 5 2 2
    4 6 2 2
    100 14 52 6
    1000000000 1000000000 1000000000 1000000000
    1000000000 1000000000 1 1

    输出#1

    1
    4
    64
    128
    512
    543661425
    121099884
    1

说明/提示

For the first test case. The only element a1,1a_{1,1} must satisfy a1,1=0a_{1,1} = 0. Since a1,1a_{1,1} must be 00, there is only 11 valid matrix: [0][0].

For the second test case.The condition requires the XOR sum of every 1×21 \times 2 submatrix to be 00. This implies ai,j⊕ai,j+1=0a_{i,j} \oplus a_{i,j+1} = 0, so ai,j=ai,j+1a_{i,j} = a_{i,j+1} for all valid i,ji,j. For each row, all elements must be equal. Thus, each row can be either [0,0,0][0, 0, 0] or [1,1,1][1, 1, 1]. With 22 rows, there are 22=42^2 =4 valid matrices.

对于第一个测试用例:唯一元素 a1,1a_{1,1} 必须满足 a1,1=0a_{1,1} = 0。由于 a1,1a_{1,1} 必须为 00,因此仅存在 11 个有效矩阵:[0][0]。

对于第二个测试用例:条件要求每个 1×21 \times 2 子矩阵的异或和为 00。这意味着对所有合法的 i,ji,j,均有 ai,j⊕ai,j+1=0a_{i,j} \oplus a_{i,j+1} = 0,即 ai,j=ai,j+1a_{i,j} = a_{i,j+1}。因此,每行中所有元素必须相等。于是,每行只能是 [0,0,0][0, 0, 0] 或 [1,1,1][1, 1, 1]。由于共有 22 行,故有效矩阵总数为 22=42^2 = 4。

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

首页