当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7249:Triangle Rotation

Special Judge 特殊评判
题目描述
You are given a triangle tower of $n$ layers. There are $i$ vertices in the $i$-th layer, and at each vertex there is an integer written on it.

Below is a figure for $n=4$.

![H2E0SS.png](https://s4.ax1x.com/2022/02/15/H2E0SS.png)

It can be shown that there are a total of $\dfrac{n(n+1)}{2}$ vertices. We guarantee that the numbers are a permutation of all integers in $[1,\dfrac{n(n+1)}{2}]$.

You need to sort the numbers, first by row and second by column, with some numbers of **triangle rotations**. A triangle rotation means:

- Select a unit triangle (the smallest non-zero triangle you can find in the figure) and rotate the numbers on its three vertices **clockwise**.

Determine whether there exists a way to sort the numbers within $2n^3$ operations. If yes, print out one of them.
输入解释
The first line contains an integer $T(1\leq T \leq 150)$ - the number of test cases.

The first line of each test case contains an integer $n(2\leq n \leq 50)$ - the number of layers of the tower.

The next $n$ lines of each test case represent the numbers in the tower. The $i$-th line contains $i$ numbers.

It is guaranteed that $\sum n^3 \leq 10^6$.
输出解释
For each test case, Output "Yes" or "No" in a single line, indicating whether there exists a way to sort the numbers within $2n^3$ operations.

If your answer is "Yes", Output an integer $k(0\leq k \leq 2n^3)$ - the number of operation you used in a single line.

For the next $k$ lines, output three integers $x,y(1 \leq x \leq n-1,1\leq y \leq 2x-1)$, indicating an operation at the $y$-th triangle between the $x$-th layer and the $x+1$-th layer.
输入样例
3
3
6
4 5
2 1 3
2
2
1 3
2
2
3 1
输出样例
Yes
11
2 3
1 1
1 1
2 3
2 3
2 2
2 1
2 1
2 2
2 3
2 3
No
Yes
2
1 1
1 1

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7249

最后修改于 2022-09-15T06:17:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 524288/524288K(Java/Others)