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

建议使用的浏览器:

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

3705:Reverse

Special Judge 特殊评判
题目描述

You will be given a list of n integers S = {1, 2, ... , (n-1), n}, please write a program to calculate the minimum number of instructions required to change the list in descending order {n, (n-1), ..., 1}. Let S[i] denote the i-th element of S, 1 ≤ in.

Each instruction takes a successive subsequence and removes that subsequence from the list, then insert that subsequence into any position of the list as a parameter. Each instruction can be represented by three numbers (pos1,length,pos2),which means we will remove subsequence S[pos1] ..... S[pos1+length-1], then insert them after the S[pos2] (pos2=0 will insert it at the beginning). We always have: 1 ≤ pos1n, 1 ≤ lengthn+1-pos1, 0 ≤ pos2n-length

For example:
The list S = {4,6,5,3,1,2},instruction (2,3,0) to get {6,5,3,4,1,2}
The list S = {4,6,5,3,1,2},instruction (3,1,2) to get {4,6,5,3,1,2}
The list S = {4,6,5,3,1,2},instruction (4,3,1) to get {4,3,1,2,6,5}
The list S = {4,6,5,3,1,2},instruction (2,4,2) to get {4,2,6,5,3,1}

输入解释

The input contains one integer n. 1 ≤ n ≤ 100

输出解释

The first line of output contains one integer C denoting the number of instructions.
Following C lines, each contains three numbers (pos1, length, pos2) for one instruction. If there are many such instructions, you can output any one of them.

输入样例
Sample Input 1
3
Sample Input 2
4
输出样例
Sample Output 1
2
1 1 2
1 1 1
Sample Output 2
3
1 2 2
1 1 1
3 1 3

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3705

最后修改于 2020-10-29T07:08:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536