CF1739A.Immobile Knight

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a chess board of size n×mn \times m. The rows are numbered from 11 to nn, the columns are numbered from 11 to mm.

Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction:

Find any isolated cell on the board. If there are no such cells, print any cell on the board.

有一个 n×mn \times m 的棋盘。行编号为 11 到 nn,列编号为 11 到 mm。

我们称一个格子是孤立的,如果将一个骑士(马)放在该格子上时,它无法移动到棋盘上的任何其他格子。回忆一下,国际象棋中骑士的走法是在一个方向上移动两格,同时在垂直方向上移动一格:

请在棋盘上找出任意一个孤立的格子。如果不存在这样的格子,则输出棋盘上的任意一个格子。

输入格式

The first line contains a single integer tt (1≤t≤641 \le t \le 64) — the number of testcases.

The only line of each testcase contains two integers nn and mm (1≤n,m≤81 \le n, m \le 8) — the number of rows and columns of the board.

第一行包含一个整数 tt(1≤t≤641 \le t \le 64)—— 测试用例的数量。

每个测试用例仅有一行,包含两个整数 nn 和 mm(1≤n,m≤81 \le n, m \le 8)—— 棋盘的行数和列数。

输出格式

For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.

对于每个测试用例,输出两个整数——棋盘上任意一个孤立单元格的行号和列号。如果不存在这样的单元格,则输出棋盘上的任意一个单元格。

输入输出样例

  • 输入#1

    3
    1 7
    8 8
    3 3

    输出#1

    1 7
    7 2
    2 2

说明/提示

In the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.

In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.

In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle.

在第一个测试用例中,所有格子都是孤立的。骑士无法从棋盘上的任意格子移动到其他任意格子。因此,棋盘上的任意格子都是正确答案。

在第二个测试用例中,不存在孤立的格子。在标准的国际象棋棋盘上,骑士从任意格子出发至少有两步可走。因此,同样地,任意格子都是正确答案。

在第三个测试用例中,仅有棋盘中央的格子是孤立的。骑士可以在棋盘边界上自由移动,但无法离开中央格子。

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

首页