AT_arc226_c.Square Corner Packing

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

There is a grid with HH rows and WW columns. Let (i,j)(i,j) denote the cell at the ii-th row from the top and the jj-th column from the left. Initially, all cells are white.

You may perform the following operation any number of times.

  • Choose integers r,c,sr,c,s satisfying all of the following conditions, and paint the cells (r,c),(r+s,c),(r,c+s),(r+s,c+s)(r,c),(r+s,c),(r,c+s),(r+s,c+s) black.

    • 1≤r<r+s≤H1\le r<r+s\le H
    • 1≤c<c+s≤W1\le c<c+s\le W
    • The cells (r,c),(r+s,c),(r,c+s),(r+s,c+s)(r,c),(r+s,c),(r,c+s),(r+s,c+s) are all white.

Find the maximum number of operations you can perform, and output one sequence of operations that achieves that maximum.

You are given TT test cases; solve each of them.

有一个 HH 行 WW 列的网格。用 (i,j)(i,j) 表示从上往下数第 ii 行、从左往右数第 jj 列的格子。初始时,所有格子均为白色。

你可以执行以下操作任意多次:

  • 选择满足以下所有条件的整数 r,c,sr,c,s,并将格子 (r,c)(r,c)、(r+s,c)(r+s,c)、(r,c+s)(r,c+s)、(r+s,c+s)(r+s,c+s) 染成黑色:

    • 1≤r<r+s≤H1\le r<r+s\le H
    • 1≤c<c+s≤W1\le c<c+s\le W
    • 格子 (r,c)(r,c)、(r+s,c)(r+s,c)、(r,c+s)(r,c+s)、(r+s,c+s)(r+s,c+s) 当前均为白色。

求最多能执行多少次该操作,并输出一个达到该最大次数的操作序列。

你将得到 TT 组测试数据;请对每组数据求解。

输入格式

The input is given from Standard Input in the following format:

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

Each test case is given in the following format:

HH WW

输入从标准输入给出,格式如下:

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

每个测试用例的格式如下:

HH WW

输出格式

For each test case, let KK be the maximum possible number of operations, and let ri,ci,sir_i,c_i,s_i be the integers chosen in the ii-th operation; output them in the following format:

KK
r1r_1 c1c_1 s1s_1
r2r_2 c2c_2 s2s_2
⋮\vdots
rKr_K cKc_K sKs_K

If there are multiple sequences of operations that achieve the maximum, any of them will be accepted.

对于每个测试用例,设 KK 为可执行操作的最大次数,ri,ci,sir_i,c_i,s_i 为第 ii 次操作中选择的整数;请按以下格式输出:

KK
r1r_1 c1c_1 s1s_1
r2r_2 c2c_2 s2s_2
⋮\vdots
rKr_K cKc_K sKs_K

若存在多种操作序列均可达到最大次数,则输出其中任意一种即可。

输入输出样例

  • 输入#1

    2
    5 6
    2 2

    输出#1

    6
    1 1 3
    3 4 2
    1 2 3
    3 3 2
    1 3 3
    2 1 1
    1
    1 1 1 135135
    66....
    664242
    135135
    ..4242

说明/提示

Sample 1 Explanation:
For the first test case, performing the six output operations paints the following cells black. The digit ii represents a cell painted black by the ii-th operation, and . represents a cell that is never painted.

There are other outputs that will be accepted.

Constraints

  • 1≤T≤5001\le T\le 500
  • 2≤H,W≤5002\le H,W\le 500
  • The sum of HWHW over all test cases is at most 250000250000.
  • All input values are integers.

样例 1 解释:
对于第一个测试用例,执行六次输出操作后,将以下格子涂成黑色。数字 ii 表示由第 ii 次操作涂黑的格子,. 表示从未被涂黑的格子。

存在其他可被接受的输出。

约束条件

  • 1≤T≤5001\le T\le 500
  • 2≤H,W≤5002\le H,W\le 500
  • 所有测试用例中 HWHW 的总和不超过 250000250000。
  • 所有输入值均为整数。

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

首页