Search is not available for this dataset
name
stringlengths 2
112
| description
stringlengths 29
13k
| source
int64 1
7
| difficulty
int64 0
25
| solution
stringlengths 7
983k
| language
stringclasses 4
values |
---|---|---|---|---|---|
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if n <= 2: print -1
else: print '%s' % ' '.join(map(str, range(n,0,-1))) | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.util.Scanner;
public class Practica_4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n == 1 || n==2) {
System.out.println(-1);
} else {
String cdn = "";
for (int i = n; i >= 1; i--) {
cdn = cdn + " " + i;
}
System.out.println(cdn.trim());
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
for i in range(n, 1, -1):
print(i, end = ' ')
print(1)
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class Solution{
///////////////////////////////////////////////////////////////////////////
static class FastScanner{
BufferedReader s;
StringTokenizer st;
public FastScanner(InputStream InputStream){
st = new StringTokenizer("");
s = new BufferedReader(new InputStreamReader(InputStream));
}
public FastScanner(File f) throws FileNotFoundException{
st = new StringTokenizer("");
s = new BufferedReader (new FileReader(f));
}
public int nextInt() throws IOException{
if(st.hasMoreTokens())
return Integer.parseInt(st.nextToken());
else{
st = new StringTokenizer(s.readLine());
return nextInt();
}
}
public BigInteger big() throws IOException{
if(st.hasMoreTokens())
return new BigInteger(st.nextToken());
else{
st = new StringTokenizer(s.readLine());
return big();
}
}
public double nextDouble() throws IOException{
if(st.hasMoreTokens())
return Double.parseDouble(st.nextToken());
else{
st = new StringTokenizer(s.readLine());
return nextDouble();
}
}
public long nextLong() throws IOException{
if(st.hasMoreTokens())
return Long.parseLong(st.nextToken());
else{
st = new StringTokenizer(s.readLine());
return nextLong();
}
}
public String nextString() throws IOException{
if(st.hasMoreTokens())
return st.nextToken();
else{
st = new StringTokenizer(s.readLine());
return nextString();
}
}
public String readLine() throws IOException{
return s.readLine();
}
public void close() throws IOException{
s.close();
}
}
////////////////////////////////////////////////////////////////////
// Number Theory
long pow(long a,long b,long mod){
long x = 1; long y = a;
while(b > 0){
if(b % 2 == 1){
x = (x*y);
x %= mod;
}
y = (y*y);
y %= mod;
b /= 2;
}
return x;
}
int divisor(long x,long[] a){
long limit = x;
int numberOfDivisors = 0;
for (int i=1; i < limit; ++i) {
if (x % i == 0) {
limit = x / i;
if (limit != i) {
numberOfDivisors++;
}
numberOfDivisors++;
}
}
return numberOfDivisors;
}
void findSubsets(int array[]){
long numOfSubsets = 1 << array.length;
for(int i = 0; i < numOfSubsets; i++){
@SuppressWarnings("unused")
int pos = array.length - 1;
int bitmask = i;
while(bitmask > 0){
if((bitmask & 1) == 1)
// ww.print(array[pos]+" ");
bitmask >>= 1;
pos--;
}
// ww.println();
}
}
public static long gcd(long a, long b){
return b == 0 ? a : gcd(b,a%b);
}
public static int lcm(int a,int b, int c){
return lcm(lcm(a,b),c);
}
public static int lcm(int a, int b){
return (int) (a*b/gcd(a,b));
}
public static long invl(long a, long mod) {
long b = mod;
long p = 1, q = 0;
while (b > 0) {
long c = a / b;
long d;
d = a;
a = b;
b = d % b;
d = p;
p = q;
q = d - c * q;
}
return p < 0 ? p + mod : p;
}
////////////////////////////////////////////////////////////////////
// FastScanner s = new FastScanner(new File("input.txt"));
// PrintWriter ww = new PrintWriter(new FileWriter("output.txt"));
static InputStream inputStream = System.in;
static FastScanner s = new FastScanner(inputStream);
static OutputStream outputStream = System.out;
static PrintWriter ww = new PrintWriter(new OutputStreamWriter(outputStream));
// private static Scanner s = new Scanner(System.in);
@SuppressWarnings("unused")
private static int[][] states = { {-1,0} , {1,0} , {0,-1} , {0,1} };
////////////////////////////////////////////////////////////////////
public static void main(String[] args) throws IOException{
new Solution().solve();
s.close();
ww.close();
}
////////////////////////////////////////////////////////////////////
void solve() throws IOException{
int n = s.nextInt();
if(n == 1 || n == 2) ww.println(-1);
else{
for(int i=n;i>=1;i--) ww.print(i+" ");
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
import java.util.stream.IntStream;
public class Codeforces{
public static void main( String[] args ){
Scanner scanner = new Scanner( System.in );
int n = scanner.nextInt( );
if( n > 2 ) IntStream.rangeClosed( 0, n - 1 ).map( i -> n - i ).forEach( i -> System.out.print( i + " " ) );
else System.out.println( -1 );
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if(n<=2)
System.out.println("-1");
else
{
for(int i=n ; i>0 ; i--)
System.out.print(i+" ");
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class A {
/**
* @param args
*/
public static void main(String[] args) {
NS ns = new NS();
if (ns.n < 3){
System.out.println("-1");
}
else {
ns.forma();
ns.print();
}
/*
ns.formda();
ns.nsort();
ns.print();
*/
}
}
class NS {
NS() {
Scanner scr = new Scanner(System.in);
n = scr.nextInt();
a = new int[n];
}
void forma(){
for (int k = 0; k < n; k++){
a[k] = n-k;
}
}
void formda(){
for (int k = 0; k < n; k++){
a[k] = k;
}
}
void nsort(){
for (int i = 0; i < n-1; i++){
for (int j = i; j < n-1; j++){
if (a[j] > a[j+1]) {
int tmp = a[j];
a[j] = a[j+1];
a[j+1] = tmp;
}
}
}
}
void print(){
for (int e: a){
System.out.print(e + " ");
}
}
int n;
int a[];
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if n == 1 or n == 2:
print -1
else:
for i in range(n, 0, -1):
print i,
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=input()
if n<3:
print -1
else:
for x in range(1,n+1)[::-1]:
print x, | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 |
n=int(raw_input())
if(n<3):
print -1
elif n==3:
print 3,2,1
else:
print 3,2,1,
for i in xrange(4,n):
print i,
print n
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, n, j, a[101];
int main() {
cin >> n;
if (n == 1 || n == 2)
cout << -1;
else
for (i = n; i >= 1; i--) cout << i << ' ';
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n >= 3:
print('3 2 1',end = ' ' )
for i in range (n - 3):
print((i + 1), end = ' ')
else:
print('-1')
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solution {
public void solve() throws IOException {
int n = in.nextInt();
if (n <= 2) {
System.out.println(-1);
} else {
for (int i = n; i >= 1; --i) {
System.out.print(i + " ");
}
}
}
public void run() throws IOException {
in = new MyScanner();
solve();
in.close();
}
private MyScanner in;
//private PrintWriter out;
public class MyScanner {
private BufferedReader br;
private StringTokenizer st;
public MyScanner() {
this.br = new BufferedReader(new InputStreamReader(System.in));
}
public MyScanner(String fileTitle) throws IOException {
this.br = new BufferedReader(new FileReader(fileTitle + ".in"));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
String s = br.readLine();
if (s == null) {
return "-1";
}
st = new StringTokenizer(s);
}
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public int[] nextIntArray(int size) throws IOException {
int[] arr = new int[size];
for (int i = 0; i < size; ++i) {
arr[i] = nextInt();
}
return arr;
}
public void close() throws IOException {
br.close();
}
}
public static void main(String[] args) throws IOException {
new Solution().run();
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | a = raw_input()
total = int(a)
if total<3:
print -1
else:
print total-1,
print total,
for i in range(0,total-2):
print 1,
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | # ~*~ coding:utf-8 ~*~
n = int(raw_input())
if n <= 2:
print -1
else:
print ' '.join(map(str, [2, 3] + [1] * (n - 2)))
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A246 {
public static void main(String args[]) throws IOException{
BufferedReader ip = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(ip.readLine());
StringBuilder sb = new StringBuilder();
if(n > 2)
{
for(;n>0;n--)
sb.append(n+" ");
System.out.print(sb);
}
else
System.out.println("-1");
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n];
if (n >= 3) {
for (int i = 0; i < n; i++) {
arr[i] = (n - i);
}
for (int i = 0; i < n; i++) {
cout << arr[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
} else
cout << "-1" << endl;
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class Ishu
{
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int n,i,j;
boolean flag=true;
int[] a=new int[50];
int[] b=new int[50];
n=scan.nextInt();
for(i=0;i<n;++i)
{
a[i]=n-i;
b[i]=a[i];
}
for(i=0;i<n-1;++i)
for(j=i;j<n-1;++j)
if(b[j]>b[j+1])
{
b[j]=b[j]+b[j+1];
b[j+1]=b[j]-b[j+1];
b[j]=b[j]-b[j+1];
}
for(i=0;i<n-1;++i)
if(!(b[i]<b[i+1]))
{
flag=false;
break;
}
if(!flag)
for(i=0;i<n;++i)
System.out.print(a[i]+" ");
else
System.out.println(-1);
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class _246_A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n=in.nextInt();
if(n<3)
System.out.println(-1);
else
for (int i = 0; i < n; i++) {
System.out.print(n-i+" ");
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | //Date: Oct 4, 2013
//Time: 3:06:52 PM
import java.util.*;
import java.io.*;
public class A246 implements Runnable {
public void solve() throws IOException {
int N = nextInt();
if(N <= 2) System.out.println(-1);
else{
for(int i = N; i > 0; i--) System.out.print(i + " ");
System.out.println();
}
}
//-----------------------------------------------------------
public static void main(String[] args) {
new A246().run();
}
public void run() {
try {
in = new BufferedReader(new InputStreamReader(System.in));
tok = null;
solve();
in.close();
} catch (IOException e) {
System.exit(0);
}
}
public String nextToken() throws IOException {
while (tok == null || !tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
public long nextLong() throws IOException {
return Long.parseLong(nextToken());
}
public double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}
BufferedReader in;
StringTokenizer tok;
}
/**
public class A246 {
}
*/ | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
bool isPrime(long long num) {
bool flag = true;
for (long long i = 2; i <= sqrt(num); i++) {
if (num % i == 0) {
flag = false;
break;
}
}
return flag;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t = 1;
while (t--) {
long long n;
cin >> n;
if (n <= 2)
cout << -1 << endl;
else {
for (long long i = n; i > 0; i--) cout << i << " ";
}
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3)
cout << -1;
else
for (int i = n; i >= 1; i--) cout << i << " ";
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1 || n == 2)
cout << -1;
else
while (n) {
cout << n << " ";
n--;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) {
cout << -1 << endl;
} else {
cout << 4 << " " << 5 << " ";
for (int i = 3; i <= n; i++) {
cout << i << " ";
}
cout << "\n";
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #main
n = int(input())
temp = []
if n<=2:
print('-1')
else:
temp.append(n)
temp.append(n)
for i in range(n-2):
temp.append(1)
for k in temp:
print(k,end=' ') | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, m;
int a[55];
int main() {
cin >> n;
if (n == 1)
cout << -1 << endl;
else if (n == 2)
cout << -1 << endl;
else {
for (int i = n; i >= 1; i--) cout << i << " ";
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.util.*;
public class AUnsuccessfulSorting {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int inputByte=sc.nextInt();
if(inputByte<3) {
System.out.print(-1);
}
else {
for(int k=inputByte; k>0; k--){
System.out.print(" "+k);
}
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long arr[N];
long long ans[N];
long long dp[N];
set<long long> adj[N];
long long vis[N] = {0};
set<long long> temp;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void solve() {
long long n;
cin >> n;
if (n <= 2) {
cout << -1 << '\n';
return;
}
for (long long i = n; i >= 1; i--) {
cout << i << " ";
}
}
int32_t main() {
fast();
long long t = 1;
while (t--) solve();
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
static BufferedReader in;
static StringTokenizer st;
static PrintWriter out;
static String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(in.readLine());
}
return st.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public static void main(String[] args) throws IOException {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(new OutputStreamWriter(System.out));
int n = nextInt();
int[] a = new int[n + 1];
if (n == 1 || n == 2) {
out.print(-1);
} else {
for (int i = n; i >= 1; i--) {
out.print(i + " ");
}
}
out.close();
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] arg)
{
new Main();
}
public Main()
{
Scanner cin=new Scanner(new BufferedInputStream(System.in));
int n=cin.nextInt();
if (n<=2) System.out.println(-1);
else
{
System.out.print(n+" "+(n-1)+" ");
for (int i=3;i<=n;i++) System.out.print((i-2)+(i==n?"\n":" "));
}
cin.close();
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n;
cin >> n;
if (n <= 2) {
cout << "-1" << '\n';
return;
}
long long int i;
for (i = n - 1; i >= 0; i--) cout << i + 1 << " ";
cout << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int t = 1;
while (t--) solve();
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;
public class Codeforces2 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n<3){
System.out.println(-1);
}else{
int t=0;
for(int i=n;i>=1;i--){
if(t==0){
System.out.print(i);
t=1;
}else{
System.out.print(" "+i);
}
}
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
print -1 if n<3 else ' '.join(map(str, [3,2,1]+range(4,n+1))) | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if(n<=2):
print('-1')
else:
ans=[ ]
while(n>0):
ans.append(n)
n-=1
print(*ans) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.applet.*;
import java.awt.*;
public class Cdfrc {
public static void main(String[] args) throws NumberFormatException,
IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
// int m = sc.nextInt();
// int[] a = new int[] { 2, 1 };
// for (int i = 1; i <= a.length - 1; i++) {
// for (int j = i; j <= a.length - 1; j++) {
// if (a[j - 1] > a[j]) {
// int tmp = a[j - 1];
// a[j - 1] = a[j];
// a[j] = tmp;
// }
// }
// }
if (n <= 2) {
System.out.println(-1);
return;
}
for (int i = n; i > 0; i--) {
System.out.print(i + " ");
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print("-1")
else:
for i in range(n, 0, -1):
print(i, end=" ") | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | N = input()
if (N <= 2):
print -1
else:
for a in range(N-1,-1,-1):
print a+1,
print
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n > 2: print(' '.join(str(i) for i in range(n, 0, -1)))
else: print(-1) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class buggysorting {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.nextLine());
if (n == 1 || n == 2)
System.out.println(-1);
else
for (int i = 0; i < n; i++)
System.out.print((((i+1)%n)+1) + " ");
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | X = int(input())
if X <= 2:
print(-1)
exit()
print(*[i for i in range(X, 0, -1)])
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | # coding: utf-8
n = int(input())
if n<=2:
print(-1)
else:
print(' '.join([str(i) for i in range(2,n+1)]+['1']))
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n <= 2: print -1
else: print ' '.join(["2"] * (n - 1) + ["1"])
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long n, e, o, res, S;
int main() {
cin >> n;
if (n <= 2)
cout << -1;
else {
for (long long i = n; i >= 1; --i) cout << i << " ";
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int arr[1000000];
long long int i, j, k, n, q, jj, bb, m, a, z, x, y, xx1, yy1, xx2, yy2, t, ans;
string s;
int main() {
cin >> n;
if ((n == 1) || (n == 2))
cout << -1;
else {
cout << n << ' ' << n - 1 << ' ';
for (i = 2; i < n; i++) cout << i - 1 << ' ';
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | def main():
i = input();
if i <= 2:
print('-1')
else:
result = '7 8 5'
for x in range (0, i-3):
result = result + ' 10'
print result
main()
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class A246 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt();
if (N <= 2) {
System.out.println("-1");
} else {
for (int n=N; n>=1; n--) {
System.out.print(n+" ");
}
System.out.println();
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | def main():
n = int(raw_input())
if n > 2:
print(' '.join(map(str,[ i for i in range(n,0,-1)] )))
else:
print(-1)
main() | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
//IO
public PrintWriter out;
private StringTokenizer tokenizer;
private BufferedReader reader;
public String next(){
while (tokenizer==null||!tokenizer.hasMoreTokens()){
try{
tokenizer=new StringTokenizer(reader.readLine());
} catch (IOException e) {throw new RuntimeException(e);}
}
return tokenizer.nextToken();
}
public int nextInt(){
return Integer.parseInt(next());
}
//Main
public Main(InputStream inputStream,OutputStream outputStream){
reader=new BufferedReader(new InputStreamReader(inputStream));
tokenizer=null;
out=new PrintWriter(outputStream);
}
public static void main(String[] args){
InputStream inputStream=System.in;
OutputStream outputStream=System.out;
//try{ inputStream=new FileInputStream("input.txt");} catch (IOException e){}
Main solver=new Main(inputStream,outputStream);
solver.solve();
solver.out.close();
}
//Solution
public void solve(){
int n=nextInt();
if (n<=2) out.println(-1);
else{
out.printf("99 100");
for (int i=3;i<=n;i++) out.printf(" 2");
out.println();
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n == 1 || n == 2) {
cout << -1;
return 0;
}
for (i = n; i >= 1; i--) cout << i << " ";
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
m = []
for i in range(1, n + 1):
m.append(n + 1 - i)
a = list(m)
a.sort()
for i in range(n - 1):
for j in range(i, n - 1):
if m[j] > m[j + 1]:
m[j], m[j + 1] = m[j + 1], m[j]
if m == a:
print(-1)
else:
a.reverse()
print(* a, sep = " ")
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
k=[i for i in range(n,0,-1)]
if n>2:
print(*k)
else:
print("-1") | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if n < 3:print -1
else:print " ".join(map(str,range(n,0,-1))) | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=input()
if n>2:
print ' '.join(map(str,[n-1]+range(1,n)[::-1]))
else:
print -1 | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
print(*[[2,2]+[1]*(n-2),[-1]][n<3]) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | //package Round_151;
import java.util.*;
import java.io.*;
public class a {
String input = "";
String output = "";
FastScanner in;
PrintWriter out;
void solve() throws Exception {
int n = in.nextInt();
int a[] = new int[n+1];
if (n < 3){
out.println(-1);
return;
}
for (int i = 2; i<=n; i++)
a[i] = n - i+ 1;
a[1] = 100;
for (int i = 1; i<=n; i++)
out.print(a[i] +" ");
}
void run() {
try {
if (input.length() == 0) {
InputStreamReader ins = new InputStreamReader(System.in);
in = new FastScanner(new BufferedReader(ins));
} else {
FileReader f = new FileReader(input);
in = new FastScanner(new BufferedReader(f));
}
if (output.length() == 0) {
out = new PrintWriter(System.out);
} else
out = new PrintWriter(new File(output));
solve();
out.flush();
out.close();
} catch (Exception ex) {
ex.printStackTrace();
out.close();
}
}
public static void main(String args[]) {
new a().run();
}
class FastScanner {
BufferedReader bf;
StringTokenizer st;
FastScanner(BufferedReader bf) {
this.bf = bf;
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(bf.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | # a=[5,4,3,2,1]
# for i in range(3):
# for j in range(3):
# if a[i]>a[i+1]:
# a[i],a[i+1]=a[i+1],a[i]
# print(a)
n=int(input())
if n==1 or n==2:print(-1)
else:print(*[ x for x in range(n,0,-1)]) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin >> n;
if (n == 0 || n == 1 || n == 2)
cout << "-1"
<< "\n";
else {
for (int i = n; i > 0; i--) cout << i << " ";
cout << "\n";
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class BuggySorting {
void run() throws Exception {
BufferedReader bfd = new BufferedReader(
new InputStreamReader(System.in));
int n = Integer.parseInt(bfd.readLine());
if(n <= 2) System.out.println(-1);
else {
while(n > 1)
System.out.print(n-- +" ");
System.out.println(n);
}
}
public static void main(String[] args) throws Exception {
new BuggySorting().run();
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n>2:print(*list(range(n,0,-1)))
else:print(-1)
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
scanf("%d", &n);
if (n < 3) {
printf("-1\n");
return 0;
}
printf("3 2 ");
for (i = 3; i <= n; i++) {
printf("1 ");
}
printf("\n");
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class Main {
public static BufferedReader reader;
public static StringTokenizer in;
public static PrintWriter out;
public static void main(String[] args) throws IOException
{
reader = new BufferedReader(new InputStreamReader(System.in));
in = new StringTokenizer("");
out = new PrintWriter(System.out);
int n = nextInt();
if(n == 1 || n == 2)
out.print(-1);
else
{
for (int i = 0; i < n; i++)
out.print(n - i + " ");
}
out.close();
}
public static void get() throws IOException
{
while(!in.hasMoreTokens())
in = new StringTokenizer(reader.readLine());
}
public static int nextInt() throws IOException
{
get();
return Integer.parseInt(in.nextToken());
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)throws IOException
{
new Main().start();
}
public void start()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
//int test=Integer.parseInt(br.readLine());
//int len=Integer.parseInt(br.readLine());
//int x = st.nextToken();
//st = new StringTokenizer(br.readLine());
//int mod = (int)(Math.pow(10,9))+7;
//int count = 0;
//3^n + 3* ((-1)^n)
//System.out.println(mod);
/*while(test --> 0){
}*/
int len = Integer.parseInt(br.readLine());
if(len == 1 || len == 2){
System.out.println(-1);
return;
}
for (int i=2; i<= len; ++i) {
System.out.print(i+" ");
}
System.out.print(1);
return;
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a, b, c, n, d, k, i;
int main() {
cin >> n;
if (n <= 2) {
cout << -1;
} else {
for (i = n; i >= 1; i--) {
cout << i << " ";
}
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j;
cin >> n;
if (n == 1 || n == 2)
cout << "-1";
else {
for (i = n; i >= 1; i--) cout << i << ' ';
}
cout << endl;
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if n <= 2: print -1
else: print ' '.join(map(str, range(n, 0, -1)))
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class buddy {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n <= 2 )
System.out.println("-1");
else {
for(int i = n; i>=1; i--)
System.out.print(i + " ");
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | def main_function():
a = int(input())
if a > 2:
return " ".join([str(a - i) for i in range(a)])
return -1
print(main_function())
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #from dust i have come dust i will be
n=int(input())
if n<=2:
print(-1)
exit(0)
print(2,n,end=' ')
for i in range(1,n):
if i!=2:
print(i,end=' ')
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
public class Main {
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter writer;
static Random random;
static int generateRandom(int n) {
return Math.abs(random.nextInt()) % n;
}
static int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
static long nextLong() throws IOException {
return Long.parseLong(nextToken());
}
static double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}
static String nextToken() throws IOException {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
public static void main(String[] args) throws IOException {
reader = new BufferedReader(new InputStreamReader(System.in));
tokenizer = null;
writer = new PrintWriter(System.out);
random=new Random();
solve();
reader.close();
writer.close();
}
private static void solve() throws IOException {
int n=nextInt();
if (n<3)
writer.print(-1);
else
{
writer.print(98+" ");
writer.print(99+" ");
for (int i=2;i<n;i++)
writer.print(i+" ");
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class A {
public static int n,a[],b[],t[];
public static void main(String args[])throws Exception{
InputStream file = System.in;
InputReader in = new InputReader(file);
int n = in.nextInt();
if(n==1||n==2)System.out.println(-1);
else
for(int i=n;i>=1;i--)
System.out.print(i+" ");
}
}
class InputReader{
public StringTokenizer token;
public BufferedReader in;
public InputReader(InputStream file)throws Exception{
in = new BufferedReader(new InputStreamReader(file));
token = null;
}
public String next(){
while(token == null || !token.hasMoreTokens()){
try{
token = new StringTokenizer(in.readLine());
}catch(Exception ex){}
}
return token.nextToken();
}
public int nextInt(){
return Integer.parseInt(next());
}
public long nextLong(){
return Long.parseLong(next());
}
public double nextDouble(){
return Double.parseDouble(next());
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
x = ''
for i in range(n,0,-1):
x += str(i) + ' '
print(x[:-1])
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
print(' '.join(map(str, list(range(2, n + 1)) + [1]))) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n <= 2:
print -1
else:
print n, n-1,
for i in range(1, n-1):
print i,
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
import java.util.stream.IntStream;
public class Solution {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n < 3)
System.out.println(-1);
else
IntStream.range(1, n + 1).map(i -> n + 1 - i).forEach(i -> System.out.print(i + " "));
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | t=int(input())
if t<3:
print(-1)
else:
for i in range(t,1,-1):
print(i,end=" ")
print(1)
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
scanf("%d", &N);
if (N <= 2)
printf("%d", -1);
else {
for (int i = N; i >= 1; i--) {
printf("%d", i);
printf(" ");
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n == 1 || n == 2) {
System.out.println(-1);
} else {
for (int i = 0; i < n; i++) {
System.out.print(n-i + " ");
}
}
//System.out.println();
//sort(n);
}
private static void sort(int n) {
int[] vals = new int[n];
for (int i = 0; i < vals.length; i++) {
vals[i] = n-i;
}
for (int i = 0; i < n-1; i++) {
for (int j = i; j < n-1; j++) {
if (vals[j] > vals[j+1]) {
int temp = vals[j];
vals[j] = vals[j+1];
vals[j+1] = temp;
}
}
}
for (int i = 0; i < vals.length; i++) {
System.out.print(vals[i] + " ");
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if(n==1 or n==2):
print(-1)
else:
l=[i for i in range(1,n+1)]
l.sort(reverse=True)
print(*l) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.math.*;
import java.io.*;
public class problem2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
if(n <=2)System.out.println(-1);
else {
for(int i=n;i>0;i--) {
System.out.print(i+" ");
}
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
def solve(lines, output):
n = int(lines.readline())
if n < 3:
output.write("-1\n")
else:
output.write(' '.join(str(x) for x in range(n, 0, -1)) + '\n')
if __name__ == '__main__':
solve(sys.stdin, sys.stdout)
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, n;
while (scanf("%d", &n) != EOF) {
if (n <= 2)
printf("-1\n");
else {
for (i = 2; i <= n; i++) printf("%d ", i);
printf("1\n");
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n == 1 || n == 2)
cout << -1 << endl;
else {
for (i = n; i >= 1; i--) {
cout << i << " ";
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print (-1)
else:
arr = [i for i in range(1,n+1)]
arr.reverse()
for i in arr:
print(i,end=' ') | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class CodeForces
{
public static void main(String[] args)
{
Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int n = input.nextInt();
if (n == 1 || n == 2)
{
System.out.println(-1);
} else
{
for (int i = 0; i < n; i++)
{
if (i == 0)
{
System.out.print(3 + " ");
} else if (i == 1)
{
System.out.print(2 + " ");
} else
{
System.out.print(1 + " ");
}
}
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0;
cin >> n;
if (n == 1 || n == 2) {
cout << -1 << endl;
} else {
for (int i = 2; i <= n; i++) {
cout << i << " ";
}
cout << 1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3) {
cout << "-1";
return 0;
}
for (int i = n; i > 0; i--) {
cout << i << " ";
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class BuggySorting {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(f.readLine());
if (n <= 2)
{
System.out.println(-1);
return;
}
for (int i = 0; i < n; i++)
System.out.print(n-i+" ");
System.out.println();
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a[101], i, j, k, n, m;
scanf("%d", &n);
if (n > 2) {
for (i = n; i > 0; i--) {
printf("%d \n", i);
}
} else {
printf("-1\n");
}
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print(-1)
else:
lst = list(range(1,n+1))
a,b = lst.pop(),lst.pop()
lst = [a,b] + lst
print(*lst) | PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | from sys import stdin,stdout,setrecursionlimit,maxint,exit
#setrecursionlimit(2*10**5)
from random import random
def listInput():
return map(long,stdin.readline().split())
def printBS(li):
for i in xrange(len(li)-1):
stdout.write("%d "%li[i])
stdout.write("%d\n"%li[-1])
n=input()
if n<=2: print -1
else:
printBS([2,3,1]+[100]*(n-3)) | PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int N, i;
int main() {
scanf("%d", &N);
if (N <= 2) {
printf("-1\n");
return 0;
}
for (i = N; i; i--) printf("%d%c", i, i == 1 ? '\n' : ' ');
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
def readints() :
l = sys.stdin.readline()
return map(int, l.split(' '))
def readstring() :
l = sys.stdin.readline()[:-1]
return l
def readint() :
l = sys.stdin.readline()
return int(l)
def clearchars(s, chars) :
for c in chars :
s = s.replace(c, '')
return s
def gcd(a, b) :
if (a < b ) :
a, b = b, a
if b == 0 :
return a
return gcd(b, a % b)
n = readint()
if n <= 2 :
print -1
else :
print ' '.join(map(str, range(n, 0, -1)))
| PYTHON |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | //package sorting;
import java.util.*;
public class Valera {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
if (N <= 2) {
System.out.print("-1");
}
else
for (int i = N; i > 0; i--) {
System.out.print(i + " ");
}
}
} | JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
print(*([-1],[3,2]+[1]*(n-2))[n>2])
| PYTHON3 |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st;
int N = Integer.parseInt(rd.readLine());
if(N<=2) pw.println(-1);
else{
for(int i=1; i<N; i++) pw.print((N+1-i)+" ");
pw.println(1);
}
pw.flush();
}
static void sort(int[] a){
for(int i=0; i<a.length-1; i++){
for(int j=i; j<a.length-1; j++){
if(a[i]>a[j]){
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
System.out.println(Arrays.toString(a));
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2)
cout << -1;
else {
while (n != 0) cout << n-- << " ";
}
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class Day_10 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if(n==1 || n==2) {
System.out.println(-1);
}else {
System.out.print((n-1)+" ");
for(int i = n; i>=1; i--) {
if(i==n-1) {
continue;
}
System.out.print(i+" ");
}
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
int fastread() {
int input;
char c = 0;
while (c < 33) c = getchar();
input = 0;
while (c > 33) {
input = input * 10 + c - '0';
c = getchar();
}
return input;
}
int main() {
int n = fastread();
int i;
if (n == 1 || n == 2)
printf("-1\n");
else
for (i = n; i >= 1; i--) printf("%d ", i);
printf("\n");
return 0;
}
| CPP |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.io.*;
public class CF246A {
public static void main(String[] args) throws IOException {
in.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
if(n<=2)
out.println(-1);
else
for(int i = n;i>0;i--)
out.print(i + " ");
out.close();
}
public static class in {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
tokenizer = new StringTokenizer("");
}
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
}
}
| JAVA |
246_A. Buggy Sorting | 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 a1, a2, ..., an 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 (aj > aj + 1), then swap the values of elements aj and aj + 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.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 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.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2)
cout << -1;
else {
for (int i = 0; i < n - 1; i++) cout << 2 << " ";
cout << 1;
}
return 0;
}
| CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.