CF246A.Buggy Sorting
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers _a_1, _a_2, ..., a__n in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (a__j > a__j + 1), then swap the values of elements a__j and a__j + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
小男生瓦列拉正在学习对整数数组进行排序的算法。在学习完理论之后,他开始做实践练习。结果,他编写了一个程序,用于将长度为 n 的整数数组 a1,a2,…,an 按非递减顺序(即升序)排序。瓦列拉所写的程序的伪代码如下所示。程序的输入为整数 n 和数组 a。
循环整数变量 i 从 1 到 n − 1
循环整数变量 j 从 i 到 n − 1
若 (a_j > a_{j+1}),则交换元素 a_j 与 a_{j+1} 的值
但瓦列拉可能出错了,因为他尚未完全掌握该排序算法。如果瓦列拉的程序存在错误,请给出一个反例,使得该程序无法正确工作(即:该例子会使程序输出的数组不是非递减顺序)。若对给定的 n 不存在这样的反例,请输出 -1。
输入格式
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
你有一个整数 $ n ( 1 \leq n \leq 50 $)——即已排序数组的大小。
输出格式
Print n space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
输出 n 个以空格分隔的整数 _a_₁, _a_₂, ..., a__n(1 ≤ a__i ≤ 100)——即 Valera 算法无法正确处理的反例。若不存在满足上述条件的反例,则输出 -1。
若存在多个由 n 个数组成的反例,你可以任选其一输出。
输入输出样例
输入#1
1
输出#1
-1
输入解题思路,AI测评打分。不知道怎么写?