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
import java.util.Scanner; /** * @author Son-Huy TRAN * */ public class P246A_BuggySorting { /** * @param args */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.close(); if (n < 3) { System.out.println(-1); } else { StringBuilder stringBuilder = new StringBuilder(); while (n > 0) { stringBuilder.append(n); stringBuilder.append(" "); n--; } System.out.println(stringBuilder.toString().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 : for i in range( 2 , n + 1 ) : print( i , end = " " ) print( 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
"""(c) gorlum0 [at] gmail.com""" import itertools as it from sys import stdin def solve(n): if n in [1, 2]: return [-1] return range(n, 0, -1) def main(): for n in it.imap(int, stdin): print ' '.join(it.imap(str, solve(n))) if __name__ == '__main__': 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 2) { cout << "2 10 "; for (int i = 0; i < n - 2; i++) cout << "1 "; } else cout << (-1); 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; template <class T> inline void mini(T &a, T b) { if (b < a) a = b; } template <class T> inline void maxi(T &a, T b) { if (b > a) a = b; } int main() { int n; cin >> n; if (n == 1 || n == 2) { puts("-1"); return 0; } for (int i = n; i >= 1; 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
n=int(input());k=[i for i in range(n,0,-1)] print(*k) if n>2 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
# bsdk idhar kya dekhne ko aaya hai, khud kr!!! # import math # from itertools import * # import random # import calendar # import datetime # import webbrowser n = int(input()) if n <= 2: print(-1) else: arr = [] for i in range(n, 0, -1): arr.append(i) print(*arr, 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
size = int(raw_input()) if size == 1 or size == 2: print -1 else: print ' '.join(map(str, range(size, 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.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); if (n < 3) { out.println(-1); } else { StringBuilder r = new StringBuilder(); for (int i = n; i > 0; i--) { r.append(i + " "); } out.println(r); } } } class InputReader { StringTokenizer tokenizer; BufferedReader reader; public InputReader(InputStream stream) { tokenizer = null; reader = new BufferedReader(new InputStreamReader(stream), 32768); } 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()); } }
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 from functools import reduce from collections import Counter import time import datetime import math # def time_t(): # print("Current date and time: " , datetime.datetime.now()) # print("Current year: ", datetime.date.today().strftime("%Y")) # print("Month of year: ", datetime.date.today().strftime("%B")) # print("Week number of the year: ", datetime.date.today().strftime("%W")) # print("Weekday of the week: ", datetime.date.today().strftime("%w")) # print("Day of year: ", datetime.date.today().strftime("%j")) # print("Day of the month : ", datetime.date.today().strftime("%d")) # print("Day of week: ", datetime.date.today().strftime("%A")) def ip(): return int(sys.stdin.readline()) def sip(): return sys.stdin.readline() def mip(): return map(int,sys.stdin.readline().split()) def mips(): return map(str,sys.stdin.readline().split()) def lip(): return list(map(int,sys.stdin.readline().split())) def matip(n,m): lst=[] for i in range(n): arr = lip() lst.insert(i,arr) return lst def factors(n): # find the factors of a number return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) def minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps jumps = [0 for i in range(n)] if (n == 0) or (arr[0] == 0): return float('inf') jumps[0] = 0 for i in range(1, n): jumps[i] = float('inf') for j in range(i): if (i <= j + arr[j]) and (jumps[j] != float('inf')): jumps[i] = min(jumps[i], jumps[j] + 1) break return jumps[n-1] def dic(arr): # converting list into dict of count return Counter(arr) def check_prime(n): if n<2: return False for i in range(2,int(n**(0.5))+1,2): if n%i==0: return False return True # --------------------------------------------------------- # # sys.stdin = open('input.txt','r') # sys.stdout = open('output.txt','w') # --------------------------------------------------------- # n = ip() if n==1 or n==2: print(-1) else: for i in range(n,0,-1): print(i,end=' ') print()
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<=2: print -1 else: for i in range(n,0,-1): print i, print ''' a = range(n,0,-1) print a for i in range(0,n-1): for j in range(i,n-1): if a[j]>a[j+1]: a[j],a[j+1] = a[j+1],a[j] print a '''
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 == 1 or n == 2: print(-1) else: print(n,end=" ") for i in range(n-1,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
import java.io.*; import java.util.*; import java.math.*; public class P246A { @SuppressWarnings("unchecked") public void run() throws Exception { int n = nextInt(); if (n <= 2) { println(-1); return; } for (int i = n; i > 0; i--) { print(i + " "); } println(""); } public static void main(String... args) throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedOutputStream(System.out)); new P246A().run(); br.close(); pw.close(); } static BufferedReader br; static PrintWriter pw; StringTokenizer stok; String nextToken() throws IOException { while (stok == null || !stok.hasMoreTokens()) { String s = br.readLine(); if (s == null) { return null; } stok = new StringTokenizer(s); } return stok.nextToken(); } void print(byte b) { print("" + b); } void print(int i) { print("" + i); } void print(long l) { print("" + l); } void print(double d) { print("" + d); } void print(char c) { print("" + c); } void print(Object o) { if (o instanceof int[]) { print(Arrays.toString((int [])o)); } else if (o instanceof long[]) { print(Arrays.toString((long [])o)); } else if (o instanceof char[]) { print(Arrays.toString((char [])o)); } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o)); } else if (o instanceof short[]) { print(Arrays.toString((short [])o)); } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o)); } else if (o instanceof float[]) { print(Arrays.toString((float [])o)); } else if (o instanceof double[]) { print(Arrays.toString((double [])o)); } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o)); } else { println("" + o); } } void print(String s) { pw.print(s); } void println(byte b) { println("" + b); } void println(int i) { println("" + i); } void println(long l) { println("" + l); } void println(double d) { println("" + d); } void println(char c) { println("" + c); } void println(Object o) { print(o); println(""); } void println(String s) { pw.println(s); } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } char nextChar() throws IOException { return (char) (br.read()); } String next() throws IOException { return nextToken(); } String nextLine() throws IOException { return br.readLine(); } int [] readInt(int size) throws IOException { int [] array = new int [size]; for (int i = 0; i < size; i++) { array[i] = nextInt(); } return array; } long [] readLong(int size) throws IOException { long [] array = new long [size]; for (int i = 0; i < size; i++) { array[i] = nextLong(); } return array; } double [] readDouble(int size) throws IOException { double [] array = new double [size]; for (int i = 0; i < size; i++) { array[i] = nextDouble(); } return array; } }
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.*; public class Main { private int N; public Integer nextInt(String s) { return Integer.valueOf(s); } public void run() { try { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); N = nextInt(bf.readLine()); if (N == 1 || N == 2) { System.out.println(-1); } else { System.out.print(N); for (int i = N - 1; i >= 1; i--) { System.out.print(" " + i); } System.out.println(); } } catch (IOException e) { } } public static void main(String[] args) { new Main().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(raw_input()) if n <= 2: print -1 else: for i in range(n): print n - i 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 < 3): 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
def main(): n = int(input()) if n <= 2: v = [-1] else: v = [int(i) for i in range(n,0,-1)] print(*v,sep = ' ') if __name__ == '__main__': main()
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
x=input() if x<=2: print '-1' else: for i in range(0,x): print x-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=int(input()) if n<=2: print(-1) else: print(*list(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
n = int(raw_input()) if n <= 2: print -1 else: print ' '.join(map(str, [x for x in 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.*; import java.io.*; import java.math.*; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} public double d() throws IOException {return Double.parseDouble(s()) ;} public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } } /////////////////////////////////////////////////////////////////////////////////////////// // RRRRRRRRR AAA HHH HHH IIIIIIIIIIIII LLL // // RR RRR AAAAA HHH HHH IIIIIIIIIII LLL // // RR RRR AAAAAAA HHH HHH III LLL // // RR RRR AAA AAA HHHHHHHHHHH III LLL // // RRRRRR AAA AAA HHHHHHHHHHH III LLL // // RR RRR AAAAAAAAAAAAA HHH HHH III LLL // // RR RRR AAA AAA HHH HHH IIIIIIIIIII LLLLLLLLLLLL // // RR RRR AAA AAA HHH HHH IIIIIIIIIIIII LLLLLLLLLLLL // /////////////////////////////////////////////////////////////////////////////////////////// public static void main(String[] args)throws IOException { PrintWriter out= new PrintWriter(System.out); Reader sc=new Reader(); int n=sc.i(); if(n<=2) out.println(-1); else for(int i=n;i>=1;i--) out.print(i+" "); out.flush(); } }
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 == 1 || n == 2) { cout << -1 << endl; 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.util.Scanner; public class Buggy { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); if(a > 2) { for(int i = a; i > 0; 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.Scanner; public class BuggySorting { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); if (n > 2) { System.out.print(3 + " " + 2 + " " + 1 + " "); for (int i = 4; i <= n; i++) { System.out.print(i + " "); } System.out.println(); } 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.io.*; import java.util.*; public class A { void run() throws IOException { int n = nextInt(); if (n < 3) { pw.print(-1); } else { for (int i = n; i >= 1; i--) pw.print(i + " "); } } String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } String nextLine() throws IOException { return br.readLine(); } PrintWriter pw; BufferedReader br; StringTokenizer st; public static void main(String[] args) throws IOException { long timeout = System.currentTimeMillis(); boolean CF = System.getProperty("ONLINE_JUDGE") != null; PrintWriter _pw = new PrintWriter(System.out); BufferedReader _br = new BufferedReader(CF ? new InputStreamReader(System.in) : new FileReader(new File("in.txt"))); new A(_br, _pw).run(); if (!CF) { _pw.println(); _pw.println(System.currentTimeMillis() - timeout); } _br.close(); _pw.close(); } public A(BufferedReader _br, PrintWriter _pw) { br = _br; pw = _pw; } }
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 <= 2: print -1 else: print ' '.join(map(str,range(1, n + 1, 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
import sys n = int(sys.stdin.readline()) if n < 3: print -1 else: print "3 5 1", for i in xrange(n-3): print "%s" % (5+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
#include <bits/stdc++.h> using namespace std; int a[10000001] = {0}; int b[10000001] = {0}; int main() { int i, j, n, k, l, r, t; scanf("%d", &n); if (n == 1 || n == 2) puts("-1"); else { for (i = n; i >= 2; 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
n = int(input()) if n <= 2: print(-1) else: numbers = [x for x in range(n, 0, -1)] print(" ".join(map(str, numbers)))
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.*; /** * * @author Andrey Siunov */ public class JavaAll01 { public static void main(String[] args) throws IOException { new JavaAll01().run(); } StreamTokenizer in; PrintWriter out; int nextInt() throws IOException { in.nextToken(); return (int)in.nval; } void run() throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } void solve() throws IOException { int n=nextInt(); if (n<=2){ out.print(-1); } else{ for (int i=0;i<n-1;i++){ out.print(2+" "); } 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; cin >> n; if (n == 1 || n == 2) cout << -1; else { cout << n << " "; for (int i = 2; i < n; i++) cout << i << " "; cout << 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author grolegor */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); if (n < 3) { out.println(-1); } else { out.print(100 + " "); out.print(99 + " "); for (int i = 0; i < n - 2; i++) { 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
import java.util.Collections; import java.util.Scanner; import java.util.Vector; public class NewClass2 { public static void main(String[] args) { Scanner ob = new Scanner(System.in); int n=ob.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
#include <bits/stdc++.h> using namespace std; int n, m, k, i, p; int main() { cin >> n; if (n < 3) { 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
import java.io.IOException; import java.util.InputMismatchException; public class BuggySorting { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); if (N <= 2) { System.out.println(-1); return; } StringBuilder sb = new StringBuilder(); for (int i = N; i > 0; i--) { sb.append(i + " "); } System.out.println(sb.toString()); } public static class FasterScanner { private byte[] buf = new byte[1024]; private int curChar; private int numChars; public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = System.in.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public String nextLine() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndOfLine(c)); return res.toString(); } public String nextString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public long nextLong() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public int nextInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { return nextIntArray(n, 0); } public int[] nextIntArray(int n, int off) { int[] arr = new int[n + off]; for (int i = 0; i < n; i++) { arr[i + off] = nextInt(); } return arr; } public long[] nextLongArray(int n) { return nextLongArray(n, 0); } public long[] nextLongArray(int n, int off) { long[] arr = new long[n + off]; for (int i = 0; i < n; i++) { arr[i + off] = nextLong(); } return arr; } private boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -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; while (scanf("%d", &n) != EOF) { if (n == 1 || n == 2) { printf("-1\n"); continue; } else { printf("100 99"); for (int i = 1; i <= n - 2; 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
N = int(raw_input() ) if( N<3 ) : print "-1" exit(0) res = [str(N)] for i in range(2,N) : res.append(str(i)) res.append("1") print " ".join( res )
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) else: s = "3 2 1" for i in range(4, n+1): s += " " + str(i) print(s)
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; void setup() {} void solve() { cin >> n; if (n == 1 || n == 2) cout << -1; else for (int i = n; i >= 1; --i) cout << i << " "; } int main() { setup(); 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
#include <bits/stdc++.h> using namespace std; void fastIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fastIO(); long long int n, t, mini, c, x, l, m, i, j, k, count; cin >> n; if (n <= 2) { cout << -1 << endl; return 0; } cout << "3 2 "; for (i = 3; i <= n; i++) { cout << "1 "; } 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
import java.util.Scanner; public class BuggySort { 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 { public static void main(String[] args){ Scanner s=new Scanner(System.in); int n=s.nextInt(); if(n<=2) 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
n = int(raw_input()) if n <= 2: print(-1) else: print('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
__copyright__ = '' __author__ = 'Son-Huy TRAN' __email__ = "[email protected]" __doc__ = '' __version__ = '1.0' def main() -> int: n = int(input()) if n <= 2: print(-1) else: result = [str(i) for i in range(n, 0, -1)] print(' '.join(result)) return 0 if __name__ == '__main__': exit(main())
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.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Queue; import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); if(n==1||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
def main(): n = int(input()) if n < 3: print(-1) else: print(' '.join([str(x) for x in range(n, 0, -1)])) if __name__ == '__main__': main()
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.Scanner; public class BuggySorting { public static void main(String[]args){ Scanner in=new Scanner(System.in); int n=in.nextInt(); if(n>2){ for(int i=n;i>1;i--) System.out.print(i + " "); System.out.println(1); }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
n = int(input()) if n<=2: print(-1) else: l=[9]*(n-1) l.append(1) print(*l, 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
#include <bits/stdc++.h> using namespace std; void sort_func(vector<int> a) { int n = a.size(); for (int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n"; for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (a[j] > a[j + 1]) { int t = a[j]; a[j] = a[j + 1]; a[j + 1] = t; } } } for (int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n"; return; } int main() { int n; cin >> n; if (n <= 2) cout << "-1"; else for (int i = n; i >= 1; i--) cout << i << " "; cout << "\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 < 3: print(-1) else: print(' '.join(map(str, [i for i 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> using namespace std; int a[200]; void cal() { int i, j, k; for (i = 0; i < 100; i++) a[i] = 100 - i; } int main() { int n, i; cal(); scanf("%d", &n); if (n == 1 || n == 2) printf("%d\n", -1); else { printf("%d", a[0]); for (i = 1; i < n; i++) printf(" %d ", a[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
#!/usr/bin/env python3 def main(): n = int(input()) if n < 3: print('-1') return arr = [str(i) for i in range(n, 0, -1)] print(' '.join(arr)) main()
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; cin >> n; if (n == 1 || n == 2) { cout << -1 << endl; } else { while (n--) { cout << n + 1 << " "; } cout << endl; } }
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.FileInputStream; import java.io.IOException; import java.math.*; import java.util.*; import javax.print.attribute.SetOfIntegerSyntax; public class Main { private static Scanner in; public static void main(String[] args) throws IOException { // helpers for input/output boolean LOCAL_TEST = true; LOCAL_TEST = false; in = new Scanner(System.in); if (LOCAL_TEST) { in = new Scanner(new FileInputStream("E:\\zin.txt")); } int n = in.nextInt(); if (n <= 2) System.out.println(-1); else { System.out.print("99 100"); for (int i = 1; i <= n - 2; i++) { System.out.print(" 1"); } } // System.out.println(sum); } }
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
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.util.*; /** * * @author N-AssassiN */ public class Main { private static BufferedReader reader; private static BufferedWriter out; private static StringTokenizer tokenizer; //private final static String filename = "filename"; /** * call this method to initialize reader for InputStream and OututStream */ private static void init(InputStream input, OutputStream output) { reader = new BufferedReader(new InputStreamReader(input)); out = new BufferedWriter(new OutputStreamWriter(output)); //reader = new BufferedReader(new FileReader(filename + ".in")); //out = new BufferedWriter(new FileWriter(filename + ".out")); tokenizer = new StringTokenizer(""); } /** * get next word */ private static String next() throws IOException { while (!tokenizer.hasMoreTokens()) { //TODO add check for eof if necessary tokenizer = new StringTokenizer(reader.readLine()); } return tokenizer.nextToken(); } private static int nextInt() throws IOException { return Integer.parseInt(next()); } private static long nextLong() throws IOException { return Long.parseLong(next()); } private static double nextDouble() throws IOException { return Double.parseDouble(next()); } /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { init(System.in, System.out); int n = nextInt(); //long startTime = System.currentTimeMillis(); if (n <= 2) { out.write("-1"); } else { for (int i = n; i >= 1; i--) { out.write(i + " "); } out.write("\n"); } //long runTime = System.currentTimeMillis() - startTime; //out.write(runTime + "\n"); out.flush(); } }
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 = input() i = n sz = 0 if (n == 1): print -1 elif (n==2): print -1 else: print n-1,n, for i in range (1,n-2): print i, print 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.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public BufferedReader input; public PrintWriter output; public StringTokenizer stoken = new StringTokenizer(""); public static void main(String[] args) throws IOException { new Main(); } Main() throws IOException{ // input = new BufferedReader( new FileReader("input.txt") ); input = new BufferedReader( new InputStreamReader(System.in) ); output = new PrintWriter(System.out); int n = nextInt(); if (n<3){ output.print(-1); } else { for (int i=n; i>0; i--){ output.print(i+" "); } } output.close(); } private int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(nextString()); } private String nextString() throws IOException { while (!stoken.hasMoreTokens()){ String st = input.readLine(); stoken = new StringTokenizer(st); } return stoken.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
n = input() if n < 3: print -1, else: while(n >= 1): print n, n -= 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
#!/usr/bin/env python n = input() print(-1 if n < 3 else ' '.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
#include <bits/stdc++.h> using namespace std; int a[55], n, j; int main() { cin >> n; if (n <= 2) cout << -1; else for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; 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
if __name__ == '__main__': n = int(input()) if n < 3: print(-1) else: print(' '.join(map(str, [3, 2, 1] + [i + 4 for i in range(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
n = int(raw_input()) print -1 if 2 >= n else ' '.join(map(lambda x: str(x), list(reversed(xrange(1, 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 = input() if n==1 or n==2: print "-1" else: print "2 3 1", n-=3 while n>0: print "1", 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
// package Practice3.CF246; import java.util.Scanner; public class CF246A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); if(n <= 2){ System.out.println(-1); }else{ StringBuilder ans = new StringBuilder(); for (int i = n; i >= 1; i--) { ans.append(i + " "); } System.out.println(ans); } } }
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[110]; int main() { int n; while (~scanf("%d", &n)) { if (n == 1 || n == 2) { printf("-1\n"); continue; } for (int i = 1; i <= n; i++) a[i] = n - i + 1; for (int i = 1; i < n; i += 2) swap(a[i], a[i + 1]); printf("%d", a[1]); for (int i = 2; i <= n; i++) printf(" %d", a[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
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n; cin >> n; if (n > 2) { for (int i = 2; i <= n; ++i) { cout << i << " "; } cout << 1 << 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
n=int(input()) if n==1 or n==2: print(-1) exit() print(*[i for i 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
#code R=lambda:map(int, input().split()) n, = R() print(-1 if n <= 2 else " ".join([str(i) for i 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> int main() { int n; scanf("%d", &n); if (n < 3) printf("-1"); else { printf("2 2 "); for (int i = 2; i < n; i++) printf("1 "); } 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.*; public class Main { 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+" "); } 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 n; scanf("%d", &n); if (n <= 2) { printf("-1\n"); return 0; } printf("3 2"); for (int 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
n=input();print ' '.join(map(str,range(n,0,-1))) if n>2 else -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
def main(): n = int(input()) if n < 3: print(-1) else: print(*list(range(n, 0, -1))) main()
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 < 3: print(-1) else: s = "3 2 1" for i in range(4, n+1): s += " " + str(i) print(s)
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 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); return; } 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
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 i=inputByte; 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 Main { /** * @param args */ public static void main(String[] args) { Scanner r = new Scanner(System.in); int N = r.nextInt(); if(N <= 2)System.out.println(-1); else{ for(int x = N; x >= 1; x--) System.out.println(x); } } }
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; scanf("%d", &n); if (n < 3) printf("-1\n"); else { for (int i = 0; i < n; i++) printf("%d ", n + 2 - 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
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; if (n <= 2) cout << -1; else { cout << 3 << ' ' << 2 << ' ' << 1 << ' '; for (int i = 4; i <= n; 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
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n <= 2) cout << "-1" << endl; else { for (int i = n; i > 1; 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
n = int(input()) res = "" if n<3: print(-1) else: for u in range(-n,0): res = res + "{} ".format(-u) print(res[:-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: arr = [] 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 = int(raw_input()) if n == 1 or n == 2: print -1 else: for i in range(2, n+1): print i, 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
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Test { static long[] a = {47, 74, 4477, 4747, 4774, 7447, 7474, 7744, 444777, 447477, 447747, 447774, 474477, 474747, 474774, 477447, 477474, 477744, 744477, 744747, 744774, 747447, 747474, 747744, 774447, 774474, 774744, 777444, 44447777, 44474777, 44477477, 44477747, 44477774, 44744777, 44747477, 44747747, 44747774, 44774477, 44774747, 44774774, 44777447, 44777474, 44777744, 47444777, 47447477, 47447747, 47447774, 47474477, 47474747, 47474774, 47477447, 47477474, 47477744, 47744477, 47744747, 47744774, 47747447, 47747474, 47747744, 47774447, 47774474, 47774744, 47777444, 74444777, 74447477, 74447747, 74447774, 74474477, 74474747, 74474774, 74477447, 74477474, 74477744, 74744477, 74744747, 74744774, 74747447, 74747474, 74747744, 74774447, 74774474, 74774744, 74777444, 77444477, 77444747, 77444774, 77447447, 77447474, 77447744, 77474447, 77474474, 77474744, 77477444, 77744447, 77744474, 77744744, 77747444, 77774444, 4444477777L}; static int Last_Ocuu(int n, int s) { int start = 0, end = s - 1, mid, ans = -1; while (start <= end) { mid = (start + end) >> 1; if (a[mid] == n) { return mid; } else if (a[mid] > n) { ans = mid; end = mid - 1; } else { start = mid + 1; } } return ans; } static boolean isvo(char s) { return (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u' || s == 'n'); } public static void main(String[] args) throws FileNotFoundException, IOException { Scannerr in = new Scannerr(System.in); try (PrintWriter or = new PrintWriter(System.out)) { int n =in.nextInt(); if(n<=2)or.print(-1); else { while (n>0) { or.print(n--+" "); } } } } static class Scannerr { StringTokenizer st; BufferedReader br; public Scannerr(FileReader fileReader) throws FileNotFoundException { br = new BufferedReader(fileReader); } public Scannerr(InputStream s) throws FileNotFoundException { br = new BufferedReader(new InputStreamReader(s)); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) { if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) { f *= 10; } } } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public boolean ready() throws IOException { return br.ready(); } } } class Pairr { int value; int index; // int min; public Pairr(int value, int index) { this.value = value; this.index = index; //min = m; } }
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 < 3: print("-1") else: for i in range(x): print((x - 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
#include <bits/stdc++.h> int main() { int n, i; while (scanf("%d", &n) != EOF) { if (n <= 2) printf("-1\n"); else { printf("%d %d ", n - 1, n); for (i = 1; i <= n - 2; i++) printf("%d%c", i, i == n - 2 ? '\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 n; int main() { cin >> n; if (n == 1 || n == 2) return cout << -1, 0; n++; while (n-- - 1) cout << 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 < 3) cout << -1; else while (n) 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.*; public class Second { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); if (n<3){ System.out.println(-1); return; } 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
n=input() print -1 if n<3 else ' '.join(map(str,[n-1,n]+range(1,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
import java.awt.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; public class Main { private static BufferedReader br; private static StringTokenizer st; private static PrintWriter pw; public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int[] list = new int[readInt()]; ArrayList<Integer> go = new ArrayList<Integer>(); for(int i = 0; i < list.length; i++) { go.add(i+1); } for(int qq = 0; qq < 1000; qq++) { Collections.shuffle(go); for(int i = 0; i < list.length; i++) list[i] = go.get(i); for(int i = 0; i < list.length-1; i++) { for(int j = i; j < list.length-1; j++) { if(list[j] > list[j+1]) { list[j] ^= list[j+1]; list[j+1] ^= list[j]; list[j] ^= list[j+1]; } } } boolean sorted = true; for(int i = 0; sorted && i < list.length-1; i++) sorted = list[i] < list[i+1]; if(!sorted) { StringBuilder sb = new StringBuilder(); for(int out: go) sb.append(out + " "); pw.println(sb.toString().trim()); pw.close(); return; } } pw.println(-1); pw.close(); } static class State { public int x,y; public State(int a, int b) { x=a; y=b; } public int hashCode() { return 3137*x+y; } public boolean equals(Object o) { State s = (State)o; return x == s.x && y == s.y; } } private static long readLong() throws IOException { return Long.parseLong(nextToken()); } private static double readDouble() throws IOException { return Double.parseDouble(nextToken()); } private static int readInt() throws IOException { return Integer.parseInt(nextToken()); } private static String nextToken() throws IOException { while(st == null || !st.hasMoreTokens()) { st = new StringTokenizer(br.readLine().trim()); } return st.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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * Created with IntelliJ IDEA. * File: Test * User: unit7 * Date: 05.10.12 * Time: 23:14 */ public class Main { public static void main(String[] args) { new Main().solve(); } private void solve() { int n = nextInt(); if(n > 2) { for(int i = n; i > 0; --i) System.out.print(i + " "); } else System.out.println(-1); } private int nextInt() { try { return Integer.parseInt(nextToken()); } catch (IOException e) { throw new RuntimeException(); } } private String nextToken() throws IOException { if(tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine()); return tokenizer.nextToken(); } StringTokenizer tokenizer; BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer; }
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[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n <=2 ) { System.out.println(-1); return; } System.out.print(n); for(int i=n; i>=2; --i) { System.out.print(" " + (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 n; cin >> n; if (n <= 2) { cout << -1; return 0; } for (int 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());l=[] if(n<=2): print(-1) else: for i in range(n,0,-1): l.append(str(i)) print(' '.join(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
#!/usr/bin/env python import sys n = int(next(sys.stdin)) if n > 2: a = [3, 2] + [1] * (n - 2) print ' '.join(map(str, a)) 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
import java.util.*; import java.io.*; public class A { static int n; public static void main(String[] main) throws IOException { Scanner input = new Scanner(System.in); n = input.nextInt(); if(n < 3) { System.out.println(-1); return; } int[] a = new int[n]; for(int i = 0; i < n; i++) if(i == 0) a[i] = 3; else if(i == 2) a[i] = 1; else a[i] = i + 1; System.out.print(a[0]); for(int i = 1; i < n; i++) System.out.print(" " + a[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
n=int(input()) f=[] for j in range(n): f.append(j+1) if n<=2: print(-1) else: print(*f[::-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; cin >> n; if (n < 3) cout << -1 << endl; else { n--; while (n--) cout << n + 2 << ' '; cout << 1 << endl; } }
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 buggy_sort(n): if n<=2: print(-1) return else: t=100 a=[] for i in range(55): a.append(t) t=t-1 for i in range(n): print(a[i],end=' ') n=int(input('')) buggy_sort(n)
PYTHON3