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
#include <bits/stdc++.h> using namespace std; int n, a[51], b[51]; int main() { int n, i; cin >> n; if (n <= 2) { cout << -1 << endl; return 0; } cout << n + 2; for (i = 2; i <= n; i++) cout << " " << n + 3 - i; cout << endl; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=input() if(n<=2): print -1 else: for i in range(1,n): print i+1, 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
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6 + 2, inf = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if (n <= 2) cout << "-1\n", exit(0); 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
import java.util.Scanner; public class BiggySorting { 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=n;i>1;i--) { System.out.println(i); } 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(raw_input()) if (n<3): print -1 else: for i in range(n,0,-1): print i
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = input() if n < 3: print -1 elif n == 3: print "2 3 1" else: print "2 3 1 " + " ".join(map(str,range(4,n+1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#Author: M@sud_P@rvez n=int(input()) if n<=2: print(-1) else: for i in range(n,0,-1): print(i,end=" ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class BuggySorting { public static void main(String[] args) { PrintWriter pw = new PrintWriter(System.out); reader(System.in); int n = nI(); if (n == 1 || n == 2) { pw.println(-1); } else { for (int i = n; i > 0; i--) { pw.print(i + " "); } } pw.close(); } private static BufferedReader br; private static StringTokenizer st; static void reader(InputStream stream) { try { br = new BufferedReader(new InputStreamReader(stream)); } catch (Exception e) { e.printStackTrace(); } } static String n() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } static int nI() { return Integer.parseInt(n()); } static long nL() { return Long.parseLong(n()); } }
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; public class BuggySorting { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); sc = new StringTokenizer(br.readLine()); int n = nxtInt(); if (n < 3) out.println(-1); else { for (int i = n; i > 0; i--) out.print(i + (i == 1 ? "" : " ")); out.println(); } br.close(); out.close(); } static BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); static StringTokenizer sc; static String nxtTok() throws IOException { while (!sc.hasMoreTokens()) { String s = br.readLine(); if (s == null) return null; sc = new StringTokenizer(s.trim()); } return sc.nextToken(); } static int nxtInt() throws IOException { return Integer.parseInt(nxtTok()); } static long nxtLng() throws IOException { return Long.parseLong(nxtTok()); } }
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; int main() { scanf("%d", &n); if (n <= 2) { printf("-1\n"); return 0; } printf("%d", n); for (n--; n; n--) printf(" %d", 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()-2 print -1 if n<1 else '2 3','1 '*n
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
from Queue import * # Queue, LifoQueue, PriorityQueue from bisect import * #bisect, insort from datetime import * from collections import * #deque, Counter,OrderedDict,defaultdict import calendar import heapq import math import copy import itertools myread = lambda : map(int,raw_input().split()) def solver(): n = input() if n == 1 or n == 2: print -1 return for i in range(n-1): print n-i, print 1 if __name__ == "__main__": solver()
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: l = [ i for i in range(n,0,-1)] print(*l,sep = ' ') else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(raw_input()) if n >= 3: print 10, print 9, print 8, for i in range(n-3): print 1, else: print -1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> int main() { int n, i, j, k, temp; while (scanf("%d", &n) == 1) { if (n < 3) printf("-1\n"); else { printf("%d", n); for (i = n - 1; i > 0; i--) printf(" %d", 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; scanf("%d", &n); if (n <= 2) printf("-1\n"); else { n -= 2; printf("2 3"); while (n--) { printf(" 1"); } printf("\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
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n < 3) cout << -1; else { cout << "5 3 2"; for (i = 4; i <= n; i++) cout << " 5"; } 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
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n < 3) cout << "-1"; else { 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=input() if n<=2: print -1 else: a = [3,2]+[1]*(n-2) for x in a: print x, 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=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
n = int(input()) j = [] if n <= 2: print(-1) else: for i in reversed(range(1, n+1)): j.append(i) print(' '.join(map(str, j)))
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.PrintWriter; import java.util.Scanner; /** * <a href="http://codeforces.ru/problemset/problem/246/A"/> * * @author pvasilyev * @since 29 Dec 2013 */ public class Problem070 { public static void main(String[] args) { final Scanner reader = new Scanner(System.in); final PrintWriter writer = new PrintWriter(System.out); solve(reader, writer); reader.close(); writer.close(); } private static void solve(final Scanner reader, final PrintWriter writer) { final int m = reader.nextInt(); if (m == 1 || m == 2) { writer.println(-1); return; } for (int i = m; i >= 1; i--) { writer.print(i + " "); } writer.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
import java.util.Scanner; public class D { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); if(n>2) { for(int i=2;i<=n;i++) { System.out.print(i+" "); } System.out.print("1"); } else { System.out.println("-1"); } scan.close(); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import sys import math from collections import defaultdict def read_line(): return sys.stdin.readline()[:-1] def read_int(): return int(sys.stdin.readline()) def read_int_line(): return [int(v) for v in sys.stdin.readline().split()] def fun(a,v): for i,k in enumerate(a[::-1]): if v>=k: return (k,8-i) return -1 n = read_int() if n<=2: print(-1) else: for i in range(1,n+1): print(n+1-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
import java.io.*; import java.util.*; import java.lang.*; public class A { public static void main (String[] argv) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()); if ((n == 1)||(n == 2)) { System.out.println("-1"); } else { System.out.print("4 5"); for (int i = 2; i < n; ++i) { System.out.print(" 2"); } 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> int main() { int n, i, j; scanf("%d", &n); if (n == 1 || n == 2) { printf("-1"); } else { for (i = n; i > 0; i--) { printf("%d ", 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 = input() if n < 3: print '-1' else: for i in range(n)[::-1]: print i + 1,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class Question246A { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n>2){ for(int i=n;i>=1;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 sys n = int(sys.stdin.readline()) if(n <= 2): print(-1) exit() res = [] for i in range(2, n + 1): res.append(str(i)) res.append(str(1)) print(" ".join(res))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=input() if n<3: print -1 else: print 2,3,1, for i in range(4,n+1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) cout << -1 << endl; else { cout << 2 << " " << 3 << " " << 1 << " "; for (int i = 0; i < n - 3; 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
n = int(raw_input()) if n == 1 or n == 2: print -1 else: print ' '.join(map(str, range(2,n+1) + [1]))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << -1; else for (int i = 0; i < n; ++i) cout << n - i << " "; 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
n = int(input()) print(-1 if n < 3 else " ".join(["100"] * (n - 1) + ["1"]))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
def bubbleSort(a, n): for i in range(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] n=int(input()) if n<=2: print(-1) else: #l=[] for i in range(n, 0, -1): print(i, end=' ') #l.append(i) """ print() bubbleSort(l, len(l)) for i in l: 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
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n; if (n < 3) cout << "-1"; else for (int i = n; i >= 1; i--) { cout << i << " "; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int inf = 1e9 + 7; void solve() { long long int n; cin >> n; if (n <= 2) { cout << "-1" << endl; } else { long long int i; for (i = n; i >= 1; i--) { cout << i << " "; } cout << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; while (t--) { solve(); } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; const long long N = 100; int main() { int n; cin >> n; if (n <= 2) cout << -1; else 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
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int n = s.nextInt(); int[] backwards = new int[n], sort = new int[n]; for(int i = 0; i < n; i++) { backwards[i] = n-i; sort[i] = i+1; } for(int i = 0; i < n-1; i++) { for(int j = i; j < n-1; j++) { if(backwards[j] > backwards[j+1]) { int temp = backwards[j]; backwards[j] = backwards[j+1]; backwards[j+1] = temp; } } } if(Arrays.equals(backwards, sort)) { System.out.println(-1); } else { for(int i = 0; i < n; i++) { if(i != n-1) out.print((n-i) + " "); else out.println(n-i); } out.flush(); } out.close(); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.*; import java.util.*; public class BuggySorting { public BuggySorting(Scanner in) { int n; int i; n = in.nextInt(); if (n >= 3) { for (i = 0; i < n; i++) { if (i > 0) System.out.printf(" "); if (i == 2) System.out.printf("1"); else System.out.printf("5"); } System.out.printf("%n"); } else System.out.printf("-1%n"); } public static void main(String[] args) { new BuggySorting(new Scanner(System.in)); } }
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 in = new Scanner(System.in); byte n = in.nextByte(); 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 main() { int n; cin >> n; if (n < 3) { cout << "-1\n"; 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
# Lista 1 PPC - K n = int(input()) if n <= 2: print("-1") else: for i in range(2,n+1): print(str(i) + " ") print(1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.StringTokenizer; import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction; public class main implements Runnable { private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringTokenizer(""); public static void main(String[] args) { // TODO Auto-generated method stub new Thread(new main()).run(); } @Override public void run() { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new OutputStreamWriter(System.out)); Solver(); pw.close(); } private void nline() { try { if (!stk.hasMoreTokens()) stk = new StringTokenizer(br.readLine()); } catch (IOException e) { throw new RuntimeException("Kernel Panic!!!!", e); } } private String nstr() { while (!stk.hasMoreTokens()) { nline(); } return stk.nextToken(); } private int ni() { return Integer.valueOf(nstr()); } private long nl() { return Long.valueOf(nstr()); } private double nd() { return Double.valueOf(nstr()); } private BigInteger nbi() { return new BigInteger(nstr()); } private String nextLine() { try { return br.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } private void Solver() { int n = ni(); if (n==1 || n==2) pw.print(-1); else { for (int i = n; i>0; i--){ pw.print(i+" "); } } } private void exit() { System.exit(0); } }
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author neuivn */ 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(); } static class TaskA { public void solve(int testNumber, InputReader in, PrintWriter out) { int N = in.nextInt(); if (N <= 2) { out.println(-1); } else { for (int j = N; j >= 1; --j) out.print(j + " "); out.println(); } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } 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
n = int(input()) if n <= 2: print(-1) else: print("2 " * (n - 1) + "1")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#!/usr/local/bin/python import sys n = int(raw_input()) if n <=2: print -1 sys.exit() a = [i for i in xrange(n, 0, -1)] print " ".join([str(i) for i in a]) """ a = map(int, raw_input().split()) for i in xrange(n-1): for j in xrange(i, n-1): if a[j] > a[j+1]: a[j+1], a[j] = a[j], a[j+1] print " ".join([str(i) for i in 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 < 3: print(-1) else: print(*[n - i for i in range(n)])
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 > 2) { for (int i = n; i >= 2; 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) 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
import java.util.*; public class Main{ public static void ValeraSort(int[] a,int n) { for(int i = 1; i < n; i++) { for (int j = i; j < n; j++) { if (a[j]>a[j+1]) { int temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] array = new int[n+1]; for (int j = 1; j <= n; j++) { array[j] = n-j+1; } //ValeraSort(array,n); if (n<3) { System.out.println(-1); } else { for(int j = 1; j <= n;j++) { System.out.print(array[j]+" "); } } } }
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.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 */ 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(); StringBuilder sb = new StringBuilder(); if (n < 3) { out.println(-1); return; } sb.append("5 "); sb.append("4 "); for (int i = 2; i < n; i++) { sb.append("2 "); } out.println(sb.toString()); } } }
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; else while (n) { cout << n << " "; n--; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) print(*((-1,), range(n, 0, -1))[n > 2])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << -1 << endl; else { for (int i = n; i > 0; i--) { if (i != n) cout << " "; cout << i; } cout << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = input() if n <= 2: print -1 else: print 2, 3, for i in xrange(n - 2): print 1,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
ri = lambda: raw_input().strip() n = int(ri()) if n == 1 or n == 2: print -1 else: for i in xrange(n, 0, -1): print 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
#include <bits/stdc++.h> const long long mod = 1000000007; using namespace std; int main() { int n; cin >> n; if (n == 1 || n == 2) cout << -1; else { for (int i = 1; i <= (n); i++) cout << (100 - i) << " "; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n <= 2: print(-1) else: for i in range (n, 0, -1): print(i, end= ' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; public class Main { 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
#include <bits/stdc++.h> using namespace std; int main() { int n, i; scanf("%d", &n); if (n <= 2) printf("-1"); else { for (i = 0; i < n; i++) { printf("%d ", n - 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 = input() if n == 1 or n == 2: print -1 else: for i in xrange(n): print n - i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=input() if n<3:print-1 else:print" ".join(map(str,[i for i 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
n = input() print [' '.join(map(str, range(n, 0, -1))), -1][n < 3]
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = input() if n<=2: print -1 else: print ' '.join(map(str,range(n,0,-1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
# Description of the problem can be found at http://codeforces.com/problemset/problem/246/A n = int(input()) if n <= 2: print(-1) else: print("2 " * (n - 1) + "1")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class A2 { public static void main(String[] args) { Scanner nik = new Scanner(System.in); int n = nik.nextInt(); if (n <= 2) { System.out.println(-1); } else { System.out.print(n - 1 + " " + n + " "); n -= 2; 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
n = int(raw_input()) if n < 3: print -1 else: for i in range(n): print n - i
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import sys n = int(sys.stdin.readline()) if n < 3: print -1 else: print ' '.join([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.StringTokenizer; import java.util.Collections; import java.util.Collection; import java.util.Set; import java.util.HashSet; import java.util.Map; import java.util.HashMap; import java.util.Arrays; import java.util.ArrayList; import java.util.Queue; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Stack; import java.util.Vector; import java.util.Hashtable; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.IOException; import java.io.FileReader; import java.math.BigInteger; public class Main { static PrintWriter writer; static StringTokenizer sz; static BufferedReader reader; public static void main(String[] args) throws Exception { declare(); int n; if ((n = Integer.parseInt(reader.readLine())) <= 2) writer.print(-1); else for (int i=n;i > 0;--i) writer.print(i + " "); close(); } private static String readString() throws IOException { return reader.readLine(); } private static void readLine() throws IOException { sz = new StringTokenizer(reader.readLine()); } private static int readInt() throws IOException { return Integer.parseInt(sz.nextToken()); } private static long readLong() throws IOException { return Long.parseLong(sz.nextToken()); } private static void declare() { writer = new PrintWriter(System.out); reader = new BufferedReader( new InputStreamReader(System.in)); } private static void declareFile() throws IOException { writer = new PrintWriter("output.txt"); reader = new BufferedReader( new FileReader("input.txt")); } private static void close() throws IOException { writer.flush(); writer.close(); reader.close(); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(raw_input()) print ' '.join(map(str,range(2,n+1) + [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
import java.util.Scanner; public class BuggySorting { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n==1 ||n==2){ System.out.println("-1"); }else{ int ans=100; for(int i=0;i<n;i++){ System.out.print(ans+" "); 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 main() { int n, i; cin >> n; int lis[100]; if (n <= 2) { cout << -1; return 0; } else { for (i = 2; i <= n; i++) { cout << i << " "; lis[i - 2] = i; } cout << 1; lis[i - 2] = 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; int main() { int n; cin >> n; if (n == 1 || n == 2) cout << -1 << endl; else { cout << n; for (int i = n - 1; i >= 1; i--) cout << " " << i; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n==1 or n==2: print(-1) else: for i in range(n): print(n-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 static java.util.Arrays.*; import java.io.*; import java.lang.reflect.*; import java.util.*; public class A { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public A () { int N = sc.nextInt(); if (N <= 2) print(-1); else { Integer [] A = new Integer[N]; for (int i = 0; i < N; ++i) A[i] = i+1; sort(A, Collections.reverseOrder()); print((Object)A); } } //////////////////////////////////////////////////////////////////////////////////// static MyScanner sc; static class MyScanner { public String next() { newLine(); return line[index++]; } public char nextChar() { return next().charAt(0); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { line = null; return readLine(); } public String [] nextStrings() { line = null; return readLine().split(" "); } public char [] nextChars() { return next().toCharArray(); } public Integer [] nextInts() { String [] L = nextStrings(); Integer [] res = new Integer [L.length]; for (int i = 0; i < L.length; ++i) res[i] = Integer.parseInt(L[i]); return res; } public Long [] nextLongs() { String [] L = nextStrings(); Long [] res = new Long [L.length]; for (int i = 0; i < L.length; ++i) res[i] = Long.parseLong(L[i]); return res; } public Double [] nextDoubles() { String [] L = nextStrings(); Double [] res = new Double [L.length]; for (int i = 0; i < L.length; ++i) res[i] = Double.parseDouble(L[i]); return res; } ////////////////////////////////////////////// private boolean eol() { return index == line.length; } private String readLine() { try { return r.readLine(); } catch (Exception e) { throw new Error(e); } } private final BufferedReader r; MyScanner () { this(new BufferedReader(new InputStreamReader(System.in))); } MyScanner(BufferedReader r) { try { this.r = r; while (!r.ready()) Thread.sleep(1); start(); } catch (Exception e) { throw new Error(e); } } private String [] line; private int index; private void newLine() { if (line == null || eol()) { line = readLine().split(" "); index = 0; } } } static void print (Object... a) { pw.println(build(a)); } static void exit (Object... a) { print(a); exit(); } static void exit () { pw.close(); System.out.flush(); System.err.println("------------------"); System.err.println("Time: " + ((millis() - t) / 1000.0)); System.exit(0); } void NO() { throw new Error("NO!"); } //////////////////////////////////////////////////////////////////////////////////// static String build(Object... a) { StringBuilder b = new StringBuilder(); for (Object o : a) append(b, o); return b.toString().trim(); } static void append(StringBuilder b, Object o) { if (o.getClass().isArray()) { int L = Array.getLength(o); for (int i = 0; i < L; ++i) append(b, Array.get(o, i)); } else if (o instanceof Iterable<?>) { for (Object p : (Iterable<?>)o) append(b, p); } else b.append(" ").append(o); } //////////////////////////////////////////////////////////////////////////////////// public static void main(String[] args) { sc = new MyScanner (); new A(); exit(); } static void start() { t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t; static long millis() { return System.currentTimeMillis(); } }
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==2 or n==1:print-1;exit() 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
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
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; // Buggy Sorting // 2012/11/21 public class P246A{ Scanner sc=new Scanner(System.in); int n; void run(){ n=sc.nextInt(); solve(); } void solve(){ if(n<=2){ println("-1"); }else{ for(int i=n; i>=1; i--){ print(i+(i==1?"\n":" ")); } } } void println(String s){ System.out.println(s); } void print(String s){ System.out.print(s); } public static void main(String[] args){ Locale.setDefault(Locale.US); new P246A().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
#include <bits/stdc++.h> using namespace std; const int N = 300000; int main() { int n; scanf("%d", &n); if (n == 1 || n == 2) printf("-1\n"); else { for (int i = n; i >= 1; i--) printf("%d ", 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
m = [] n = int(input()) for i in range(1, n + 1): m.append(n + 1 - i) a = list(m) a.sort() for i in range(n - 1): for j in range(i, n - 1): if m[j] > m[j + 1]: m[j], m[j + 1] = m[j + 1], m[j] if m == a: print(-1) else: a.reverse() print(* a, sep = " ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; public final class BuggySorting { public static void main(String arg[]) { Scanner br=new Scanner(System.in); int n=br.nextInt(); if(n<=2) System.out.println("-1"); else { for(int i=1;i<n;i++) System.out.print((i+1)+" "); System.out.print("1"); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n > 2: print(" ".join(map(str,list(range(n,0,-1))))) else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int n, a[55], i; int main() { cin >> n; if (n == 1 || n == 2) cout << -1; else { a[1] = 90; a[2] = 89; for (i = 3; i <= n; i++) a[i] = i; for (i = 1; i <= n; i++) cout << a[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 BuggySorting { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.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.*; public class BuggySorting { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n<=2) System.out.println("-1"); else { for(int i=n;i>=1;i--) System.out.print(i+" "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; map<long long int, long long int> mp, mk; set<long long int> s1, s2; vector<long long int> v, w; long long int a[2000006], b[2000006]; string s = "", p = "", q = ""; char ch; long long int m, n, c, i, j, k, l, r, x, t, y, u, e, f, g, h, mn, mx, d; int main() { cin >> n; if (n <= 2) cout << -1; else for (i = n; i > 0; i--) cout << i << " "; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.*; import java.math.BigInteger; import java.util.*; public class B implements Runnable { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) { new Thread(null, new B(), "", 128 * (1L << 20)).start(); } void init() throws FileNotFoundException { Locale.setDefault(Locale.US); if (ONLINE_JUDGE) { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else { in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } } long timeBegin, timeEnd; void time() { timeEnd = System.currentTimeMillis(); System.err.println("Time = " + (timeEnd - timeBegin)); } public void run() { try { timeBegin = System.currentTimeMillis(); init(); solve(); out.close(); time(); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } } String readString() throws IOException { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine()); } catch (Exception e) { return null; } } return tok.nextToken(); } String readString(String s) throws IOException { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine(), s + "\n \t"); } catch (Exception e) { return null; } } return tok.nextToken(); } double readDouble() throws IOException { return Double.parseDouble(readString()); } int readInt() throws IOException { return Integer.parseInt(readString()); } long readLong() throws IOException { return Long.parseLong(readString()); } int readInt(String s) throws IOException { return Integer.parseInt(readString(s)); } boolean isPrime(int a) throws IOException { int del=0; if(a==2){ return false; } for(int i=2;i<Math.sqrt(a)+1;i++){ if(a%i==0){ del=i; break; } } if(del>0){ return false; } else return true; } public BigInteger factorial(int num) throws IOException { BigInteger fact = new BigInteger("1"); BigInteger i = new BigInteger("1"); BigInteger one = new BigInteger("1"); for (int j=0;j<num;j++) { fact = fact.multiply(i); i=i.add(one); //out.println(fact.toString()+" "+i.toString()); } //fact = fact.add(one); return fact; } public int[] readIntArr(int n) throws IOException{ int[] a = new int[n]; for(int i=0;i<n;i++){ a[i] = readInt(); } return a; } void solve() throws IOException{ int n = readInt(); if(n==1 || n==2){ out.println(-1); }else{ for(int i=0;i<n;i++){ out.print(n-i+" "); } } } public long fn(long n) throws IOException{ return 0; } }
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; int main() { cin >> n; if (n <= 2) { cout << "-1"; } else { 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(raw_input()) if n<3: print -1 else: ans=range(1,n+1)[::-1] print ' '.join(map(str,ans))
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 << "-1" << endl; else { while (n) { cout << n << " "; n -= 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.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); Random rand = new Random(); int N = sc.nextInt(); int[] array = new int[N]; int[] begin = new int[N]; for(int a=0;a<N;a++)array[a]=N-a; begin = array.clone(); // array[N-1]=N; sort(array); if(sorted(array))System.out.println("-1"); else { for(int a=0;a<N;a++)System.out.print(begin[a]+" "); } //System.err.println(Arrays.toString(array)); } private static boolean sorted(int[] array) { for(int a=0;a<array.length-1;a++) if(array[a]>array[a+1])return false; return true; } private static void sort(int[] array) { int N = array.length; for(int i = 1-1;i<=N-1-1;i++){ for(int j=i;j<=N-1-1;j++){ if(array[j]>array[j+1]){ int temp = array[j]; array[j]=array[j+1]; array[j+1]=temp; } } } } static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(InputStream in) throws Exception{ br = new BufferedReader(new InputStreamReader(in)); st = new StringTokenizer(br.readLine().trim()); } public int numTokens() throws Exception { if(!st.hasMoreTokens()){ st = new StringTokenizer(br.readLine().trim()); return numTokens(); } return st.countTokens(); } public String next() throws Exception { if(!st.hasMoreTokens()){ st = new StringTokenizer(br.readLine().trim()); return next(); } return st.nextToken(); } public double nextDouble() throws Exception{ return Double.parseDouble(next()); } public float nextFloat() throws Exception{ return Float.parseFloat(next()); } public long nextLong() throws Exception{ return Long.parseLong(next()); } public int nextInt() throws Exception{ return Integer.parseInt(next()); } public String nextLine() throws Exception{ return br.readLine().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
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class BuggySorting { static BufferedReader in; static Scanner sn; static StringTokenizer tk; public static void main(String... args) throws IOException { // in = new BufferedReader(new FileReader(".in")); // in = new BufferedReader(new InputStreamReader(System.in)); // sn = new Scanner(new BufferedInputStream(new FileInputStream(".in"))); sn = new Scanner(new BufferedInputStream(System.in)); int n = sn.nextInt(); if (n <= 2){ System.out.println(-1); } else { for (int i = n; i >= 1; i--){ System.out.print(i); if (i > 1){ System.out.print(" "); } } 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) { 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
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; if (n <= 2) { cout << -1 << "\n"; } else { for (int i = n; i >= 1; i--) { cout << i << " "; } cout << "\n"; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); auto start = std::chrono::high_resolution_clock::now(); int t = 1; while (t--) solve(); auto stop = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); cerr << "\nTime taken : " << ((long double)duration.count()) / ((long double)1e9) << " s " << 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 A_246_Buggy_Sorting { 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 = 0; i < n; i++) { System.out.println((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 " ".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
n = input() print -1 if n <= 2 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
FILE = "P1" try: inFile = open(FILE+".txt") except: pass def read(): try: return inFile.readline().strip() except: return raw_input().strip() n = int(read()) if n <= 2: print -1 else: for i in xrange(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
from sys import stdin,stdout import bisect import math def st(): return list(stdin.readline().strip()) def inp(): return int(stdin.readline()) def li(): return list(map(int,stdin.readline().split())) def mp(): return map(int,stdin.readline().split()) def pr(n): stdout.write(str(n)+"\n") def soe(limit): l=[1]*(limit+1) prime=[] for i in range(2,limit+1): if l[i]: for j in range(i*i,limit+1,i): l[j]=0 for i in range(2,limit+1): if l[i]: prime.append(i) return prime def segsoe(low,high): limit=int(high**0.5)+1 prime=soe(limit) n=high-low+1 l=[0]*(n+1) for i in range(len(prime)): lowlimit=(low//prime[i])*prime[i] if lowlimit<low: lowlimit+=prime[i] if lowlimit==prime[i]: lowlimit+=prime[i] for j in range(lowlimit,high+1,prime[i]): l[j-low]=1 for i in range(low,high+1): if not l[i-low]: if i!=1: print(i) def power(a,n): r=1 while n: if n&1: r=(r*a) a*=a n=n>>1 return r def solve(): n=inp() if n<=2: pr(-1) else: for i in range(n,0,-1): print(i,end=" ") for _ in range(1): solve()
PYTHON3