Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A_246 { FastScanner in; PrintWriter out; public void run() { try { in = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } catch (IOException e) { e.printStackTrace(); } } public void solve() throws IOException { int n = in.nextInt(); if (n == 1 || n == 2) { out.println(-1); return; } StringBuilder sb = new StringBuilder(); for (int i=n; i>=1; i--) { sb.append(i); sb.append(' '); } sb.deleteCharAt(sb.length()-1); out.println(sb); } class FastScanner { BufferedReader br; StringTokenizer st; FastScanner(InputStreamReader in) { br = new BufferedReader(in); } String nextLine() { String str = null; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } } public static void main(String[] arg) { A_246 o = new A_246(); o.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; void solve() { long long int n; cin >> n; if (n > 2) { for (long long int i = 0; i < n - 1; i++) cout << 2 << " "; cout << 1 << endl; } else cout << -1 << endl; } void testcase() { int t; cin >> t; while (t--) { solve(); } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class BuggySort { public static void main(String []args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); if(n < 3) {System.out.println("-1"); return; } for(int i = 1; i < n + 1; ++i) { if(i == 1) System.out.print("2 "); else if(i == 2) System.out.print("3 "); else if(i == 3) System.out.print("1 "); else System.out.print(i+" "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
a=int(input()) if a<=2:print(-1) else:print(' '.join(list(map(str,range(1,a+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 A_151 { 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 { for (int i =n; i >=1; i--) { System.out.print(i+" "); } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; import java.io.*; public class codeforce { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n<=2) System.out.println(-1); else { System.out.print("2 3 1"); for(int i = 0; i<n-3; i++) System.out.print(" 5"); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = input() if n < 3: print -1 else: l = range(n, 0, -1) for i in l: 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 n; int main() { cin >> n; if (n <= 2) cout << -1; else { for (int i = 2; i <= n; ++i) cout << i << " "; cout << 1; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=int(raw_input()) if n<3: print -1 else: l=range(n) l.reverse() s="" for i in l: s=s+str(i+1)+" " print s
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << "-1\n"; 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main implements Runnable { private static void solve() throws IOException { int n = nextInt(); if( n <= 2 ){ out.println(-1); }else{ out.print("2 3 1 "); for( int i = 4; i <= n; ++i ) out.print(i+" "); } } private static BufferedReader in; private static PrintWriter out; private static StringTokenizer st; static int nextInt() throws IOException { return Integer.parseInt(next()); } static long nextLong() throws IOException { return Long.parseLong(next()); } static double nextDouble() throws IOException { return Double.parseDouble(next()); } static String next() throws IOException { while (!st.hasMoreTokens()) { String line = in.readLine(); if (line == null) return null; eat(line); } return st.nextToken(); } private static void eat(String s) { st = new StringTokenizer(s); } public static void main(String[] args) { new Thread(null, new Main(), "Main", 1 << 27).start(); } public void run() { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); eat(""); solve(); in.close(); out.close(); } catch (IOException e) { e.printStackTrace(); System.exit(566); } } }
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 teste{ public static void main (String[] args){ int n = new Scanner(System.in).nextInt(); if(n < 3) System.out.println(-1); else{ for(int i = n; i>0; i--) System.out.println(i); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=int(raw_input()) print ' '.join(map(str,[ i for i in 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<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
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 k=inputByte; k>0; k--){ System.out.print(" "+k); } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
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 java.lang.*; import java.util.*; import java.math.*; public class MyClass{ static class Pair implements Comparable<Pair>{ long a, b; public Pair(long a, long b) { this.a = a; this.b = b; } @Override public int compareTo(Pair o) { return Long.compare(a, o.a); } } public static boolean prime(long x) { if(x<=1)return false; for(int i=2;i*i<=x;i++) { if(x%i==0) return false; } return true; } /* public static BigInteger decimal(String bi) { return new BigInteger(bi, 2); }*/ /*public static int log(int k) { int ans = (int)(Math.log(k) / Math.log(2)); return ans; }*/ /* public static int gcd(int a,int b) { if (b== 0) return a; return gcd(b,a%b); }*/ /* public static int cal(int num) { int k=1,ans=0; while(num>0) { int d=num%10; if(d!=0) { ans=ans+d*k; k=k*10; } num=num/10; } return ans; }*/ public static void main(String args[]) { Scanner sc=new Scanner(System.in); /* int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); long d=sc.nextLong(); long a=sc.nextLong(); long b=sc.nextLong(); ArrayList<Long> fi=new ArrayList<Long>(); for(int i=0;i<n;i++) { long x=sc.nextLong(); long y=sc.nextLong(); p.add(new Pair((x*a)+(y*b),i+1)); } Collections.sort(p); long r=0; for(int i=0;i<n;i++){ if(r+p.get(i).a <= d){ r+=p.get(i).a; fi.add(p.get(i).b); } else break; } System.out.println(fi.size()); for(long i:fi) System.out.print(i+" ");*/ int n=sc.nextInt(); if(n<3) 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
n=int(raw_input()) if n==1 or n==2: print '-1', else : for i in range(n,0,-1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
//This code is written by प्रविण शंखपाळ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collections; import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedList; import java.util.Stack; import java.util.Queue; import java.util.PriorityQueue; import java.util.List; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.TreeSet; import java.util.Map; import java.util.HashMap; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; import java.util.Vector; import javafx.util.Pair; public class Ginny_Weasley { static long A[] = new long[(int) 1e6 + 1]; static int mod = (int) 1e9 + 7; static long fib(int n) { A[0] = 0; A[1] = 1; for (int i = 2; i <= n; i++) { A[i] = (A[i - 1] + A[i - 2]) % mod; } return A[n]; } public static void main(String[] args) { try { FastReader fr = new FastReader(); int n = fr.nextInt(); if (n <= 2) { System.out.println(-1); } else { for (int i = n; i > 0; i--) { System.out.print(i + " "); } } } catch (Exception e) { return; } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; import java.util.Scanner; import java.io.*; import javax.lang.model.util.ElementScanner6; import static java.lang.System.out; public class A246 { public static void main(String args[]) { FastReader in=new FastReader(); PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int tc=1; //tc=in.nextInt(); while(tc-->0) { int n=in.nextInt(); if(n<3){pr.println(-1); break;} int arr[]=new int[n]; arr[0]=n; arr[1]=n-1; for(int i=2;i<n;i++) { arr[i]=i-1; } for(int i : arr)pr.print(i+" "); pr.println(); /* for(int i=0;i<n-1;i++) { for(int j=i;j<n-1;j++) { if(arr[j]>arr[j+1]) { int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } for(int i : arr)pr.print(i+" "); pr.println(); */ } pr.flush(); } static void sort(long[] a) { ArrayList<Long> l = new ArrayList<>(); for (long i : a) l.add(i); Collections.sort(l); for (int i = 0; i < a.length; i++) a[i] = l.get(i); } static void sort(int[] a) { ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); Collections.sort(l); for (int i = 0; i < a.length; i++) a[i] = l.get(i); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
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
/** * @author panicker */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemA { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } } class Task { public void solve(int testNumber, InputReader in, PrintWriter out) { int N = in.nextInt(); if (N > 2) { for (int i = N; i > 0; i--) { out.print(i + " "); } } else { out.print(-1); } } } 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): for i in range(2,n+1,1): print(i,end=' ') print(1) else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class P246A { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner (System.in); int n = in.nextInt(); if (n<=2) System.out.println(-1); else { String out = ""; for (int i=0; i<n; i++) out += 60-i + " "; System.out.println(out.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
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf("%d", &n) != EOF) { if (n < 3) { puts("-1"); continue; } printf("%d %d", n, n - 1); for (int i = 2; i < n; i++) printf(" %d", i - 1); puts(""); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n > 2: print(*tuple(range(n+1)[: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
n = input() print -1 if n < 3 else ' '.join([`3`, `2`] + [`1`] * (n - 2))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.InputStreamReader; import java.util.*; public class d2_151_A { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n==1 || 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 num; while (scanf("%d", &num) != EOF) { if (num > 2) { while (num) { cout << num << " "; num--; } cout << endl; } else { cout << -1 << endl; } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class A264 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); if (a<3) { System.out.println("-1"); }else { for (int i=a;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> int main(void) { int n, a[50], i; scanf("%d", &n); if (n < 3) printf("-1\n"); else { for (i = n; i >= 1; i--) printf("%d ", i); printf("\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
''' Codeforces Round #151 (Div. 2) | A - Buggy Sorting ''' try: n = int(input()) ans = '-1' if n <= 2 else ' '.join([str(i) for i in range(n, 0, -1)]) print(ans) except EOFError as e: pass
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=int(input()) l=[] if n<=2: print(-1) else: for i in range(n,0,-1): l.append(i) for r in l: print(r,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, num[100]; while (~scanf("%d", &n)) { if (n == 1 || n == 2) { printf("-1\n"); continue; } for (int i = 1; i <= n; i++) printf("%d ", n - i + 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) { cout << -1 << endl; } else { for (int i = 2; i <= n; i++) { cout << i << " "; } cout << 1 << endl; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class P246A { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int num = sc.nextInt(); if (num <= 2) { System.out.println("-1"); System.exit(0); } System.out.print("2 3 1"); int k = 4; for (int i = 3; i < num; i++) { System.out.print(" " + k); k++; } sc.close(); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Scanner; public class A { 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-1; i++) System.out.print(3+" "); 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
import sys import copy import os def main(cin): n = int(cin.readline().strip()) if n<3: print -1 return s = ['3','2'] for i in range(n-2): s.append('1') print ' '.join(s) if __name__ == "__main__": cin = sys.stdin if (os.path.exists('best.txt')): cin = open('best.txt') main(cin)
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; import java.io.*; import java.math.BigInteger; public class a { public static void main(String[] arg) throws IOException { new a(); } public a() throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); if(n == 1 || n == 2) out.println(-1); else { for(int i = n; i > 0; i--) { out.print(i + " "); } } in.close(); out.close(); } class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); st = new StringTokenizer(""); } public String next() throws IOException { while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public void close() throws IOException { br.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(input()) if n > 2: print(*range(2,n+1), 1) else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long int n; scanf("%lld", &n); if (n <= 2) printf("-1"); else { for (int i = n; i >= 1; i--) printf("%d ", 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.util.*; public class Main{ public static void main(String[] args){ try{ Scanner s = new Scanner(System.in); int n = s.nextInt(); if(n <= 2){ System.out.printf("-1"); }else{ for(int i = n; i > 0; i--){ System.out.printf("%d", i); if(i != 1) System.out.printf(" "); } } }catch(Exception e){ e.printStackTrace(); } } }
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
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(const T& x) { return x * x; } template <class T> inline string tostr(const T& a) { ostringstream os(""); os << a; return os.str(); } const int inf = 1999999999; const double pi = acos(-1.0); const double eps = 1e-9; int main() { clock_t _ = clock(); ios::sync_with_stdio(false); cout << fixed << setprecision(15); int n; cin >> n; if (n == 1 || n == 2) { cout << -1 << ('\n'); return 0; } cout << 100 << ' ' << 99 << ' '; for (int i = 0; i < n - 2; i++) cout << "1" << ' '; cout << ('\n'); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; public class bucky{ private int contor=0; public static void main (String args[]) { Scanner input=new Scanner(System.in); HashMap<Integer, Integer> map= new HashMap<Integer, Integer>(); HashMap<Integer, Integer> start= new HashMap<Integer, Integer>(); HashMap<Integer, Integer> finish= new HashMap<Integer, Integer>(); HashMap<Integer, Integer> maxime= new HashMap<Integer, Integer>(); int n=input.nextInt(); if(n<3) 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; #pragma comment(linker, "/STACK:16777216") const double EPS = 1e-7; double iabs(const double a) { return (a < -EPS) ? -a : a; } double imin(const double a, const double b) { return (a - b > EPS) ? b : a; } double imax(const double a, const double b) { return (a - b > EPS) ? a : b; } template <class I> I iabs(const I a) { return (a < 0) ? -a : a; } template <class I> I imin(const I a, const I b) { return (a < b) ? a : b; } template <class I> I imax(const I a, const I b) { return (a < b) ? b : a; } template <class I> inline I mod_pow(const I& x, const long long p, const I& m) { if (p == 0) return 1; I mult = (p & 1) ? x : 1; I t = mod_pow(x, p / 2, m) % m; return (((mult * t) % m) * t) % m; } template <class T> inline T ipow(const T& x, const long long p) { if (p == 0) return 1; T mult = (p & 1) ? x : 1; T h = ipow(x, p / 2); return h * h * mult; } unsigned long long gcd(unsigned long long a, unsigned long long b) { if (a == 0) return b; return gcd(b % a, a); } template <int SIZE> class DSU { public: int parent[SIZE]; int rank[SIZE]; int count; void clear() { for (int i = 0; i < SIZE; i++) { this->parent[i] = -1; this->rank[i] = 0; } this->count = 0; } DSU() { this->clear(); } void make(int x) { this->parent[x] = x; this->rank[x] = 1; this->count++; } bool in_a_set(int x) { return this->parent[x] != -1; } int find(int x) { if (x == this->parent[x]) return x; return this->parent[x] = find(this->parent[x]); } void combine(int x, int y) { x = this->find(x); y = this->find(y); if (x != y) { if (this->rank[x] > this->rank[y]) this->parent[x] = y; else this->parent[y] = x; } } }; class BigInt { public: const static unsigned int N = 1000; const static unsigned int base = 10; unsigned int len; short sign; unsigned int digits[N]; BigInt(const BigInt& bi) { this->len = bi.len; this->sign = bi.sign; for (unsigned int i = 0; i < this->len; ++i) (*this)[i] = bi[i]; } BigInt(long long n) { this->len = 0; this->sign = (n >= 0) ? 1 : -1; this->digits[0] = 0; while (n) { this->digits[this->len] = n % this->base; n /= this->base; this->len++; } if (this->len == 0) this->len = 1; } BigInt(string s) { this->sign = (s[0] == '-') ? 1 : -1; this->digits[0] = 0; if (s[0] == '-') s = s.substr(1, s.length() - 1); this->len = s.length(); for (unsigned int i = 0; i < this->len; i++) (*this)[i] = s[this->len - i - 1] - '0'; } string toString() const { stringstream ss; for (int i = this->len - 1; i >= 0; --i) ss << (*this)[i]; return ss.str(); } unsigned int& operator[](const unsigned int i) { return digits[i]; } unsigned int operator[](const unsigned int i) const { if (i < this->len) return this->digits[i]; return 0; } bool iszero() const { if (this->len <= 1 && this->digits[0] == 0) return true; return false; } BigInt& operator=(const BigInt& rval) { if (this != &rval) { this->len = rval.len; this->sign = rval.sign; for (unsigned int i = 0; i < this->len; ++i) (*this)[i] = rval[i]; } return *this; } BigInt operator+(const BigInt& rhs) const { BigInt s(0); unsigned long long r = 0, d, i; for (i = 0; i < max(this->len, rhs.len); i++) { d = (*this)[i] + rhs[i] + r; r = d / this->base; s[i] = d % this->base; } s.len = max(this->len, rhs.len); if (r) s[s.len++] = r; return s; } BigInt operator+(unsigned long long rhs) const { BigInt s(*this); unsigned long long r = 0, d, i = 0; while (rhs != 0 || r != 0) { d = s[i] + (rhs % s.base) + r; rhs /= s.base; r = d / s.base; s[i] = d % s.base; i++; } if (i > s.len) s.len = i; return s; } BigInt operator*(unsigned long long rhs) const { if (rhs == 0) return BigInt(0); BigInt s(*this); unsigned long long r = 0, d, i; for (i = 0; i < s.len; ++i) { d = s[i] * rhs + r; r = d / this->base; s[i] = d % this->base; } while (r) s[s.len++] = r % this->base, r /= this->base; return s; } BigInt operator*(const BigInt& rhs) const { BigInt s(0); if (rhs.iszero()) return s; unsigned long long r, d, i, j, k; for (i = 0; i < this->N; i++) s[i] = 0; for (i = 0; i < this->len; i++) { r = 0; for (j = 0, k = i; j < rhs.len; j++, k++) { d = (*this)[i] * rhs[j] + r + s[k]; r = d / this->base; s[k] = d % this->base; } while (r) s[k++] = r % this->base, r /= this->base; if (k > s.len) s.len = k; } while (s.len > 1 && s[s.len - 1] == 0) s.len--; return s; } unsigned int operator%(unsigned int rhs) { BigInt t(*this); unsigned long long pow = 1; unsigned long long mod = 0; for (unsigned int i = 0; i < this->len && pow != 0; i++) { mod = (((*this)[i] % rhs) * pow + mod) % rhs; pow = (pow * this->base) % rhs; } return mod; } }; vector<long long> genprimes(const int n) { vector<long long> res; res.push_back(2); long long m, t, j; for (int i = 3; i <= n; i++) { j = 0; m = res.size(); t = (long long)sqrt(i * 1.0) + 1; while (j < m && res[j] < t && i % res[j] != 0) j++; if (j == m || res[j] >= t) res.push_back(i); } return res; } const unsigned long long N = 1000; const long long INF = 100000000; long long n, m, i, j, k, t, d; int main(int argc, char* argv[]) { cin >> n; if (n < 3) cout << "-1\n"; else { for (i = n; i > 0; i--) cout << i << " "; cout << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import bisect from itertools import accumulate import os import sys import math from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) def input(): return sys.stdin.readline().rstrip("\r\n") # ------------------- fast io -------------------- n=int(input()) if n==1 or 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.Scanner; //int ar[] =new int[1001]; //st.charAt(i) public class Watermelon { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n; n= in.nextInt(); if(n<=2){ System.out.print("-1"); } else{ for(int i=n;i>0;i--){ System.out.print(i + " "); } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(raw_input()) 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
import java.util.Scanner; public class BuggySorting { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); if(n==1 || 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
n=int(input()) if n<=2: print(-1) else: print(*[i for i in range(n,0,-1)])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
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]; fill(A, 1); A[0] = 2; A[1] = 3; print(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();print-1if 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
import sys n = int(sys.stdin.readline()) if(n <= 2): print(-1) exit() res = [] for i in range(n, 0, -1): res.append(str(i)) 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
#include <bits/stdc++.h> int n; int main() { scanf("%d", &n); if (n <= 2) { printf("%d", -1); return 0; } for (; 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
import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author rais.fathin38 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); if(n == 1 || n == 2) out.printLine(-1); else { for(int i = n; i > 0; i--) out.print(i + " "); out.printLine(""); } } } class InputReader { public BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (Exception e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object...objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object...objects) { print(objects); writer.println(); } public void close() { writer.close(); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 2) { for (int i = 0; i < n; i++) { cout << n - i << " \n"[i == n - 1]; } return 0; } cout << -1 << endl; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int a; scanf("%d", &a); if (a == 1 || a == 2) { printf("%d\n", -1); return 0; } printf("6 3"); for (int i = 2; i < a; i++) { printf(" %d", i); } printf("\n"); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
def main(): n = int(raw_input()) if n < 3: print -1 else: print 2,3, for i in range(2,n): print 1, if __name__ == "__main__": main()
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
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
a = int(input()) if (a == 2) | (a == 1): print(-1) else: while a > 0: print(a, end = " ") a = a - 1
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); if (n <= 2) printf("%d\n", -1); else { for (int i = n; i > 0; --i) printf("%d ", i); printf("\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int n, a[52]; int main() { scanf("%d", &n); if (n < 3) { printf("-1"); return 0; } for (int i = n; i > 1; i--) printf("%d ", i); printf("1"); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
def try_sort(array): n = len(array) for i in range(n): for j in range(i, n-1): if array[j] > array[j+1]: array[j], array[j+1] = array[j+1], array[j] return array def main(): n = int(raw_input()) if n == 1 or n == 2: print -1 else: a = [] for i in range(n, 0, -1): a.append(str(i)) #a.append(i) #print try_sort(a) print " ".join(a) main()
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = t_int(br); if (n <= 2) { System.out.println(-1); } else { for (int i = n; i > 1; i--) { System.out.print(i + " "); } System.out.println(1); } br.close(); } public static int t_int(BufferedReader br) throws Exception { return Integer.parseInt(br.readLine()); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
a=int(input("")) if (a==1 or a==2): print(-1) else: for g in range (a,0,-1): print(g)
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
a=int(input()) if a==1 or a==2: print(-1) else: x='' x+=(a-1)*'2 ' x+='1' print(x)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.*; import java.util.*; public class Example { BufferedReader in; PrintWriter out; StringTokenizer st; String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(in.readLine()); } catch (Exception e) { } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } public void run() throws Exception { //in = new BufferedReader(new FileReader("D.IN")); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.flush(); out.close(); in.close(); } public void solve() throws Exception { int n = nextInt(); if (n <= 2) { out.println(-1); } else { out.print(n - 1 + " " + n + " "); for (int i = 2; i < n; i++) { out.print(1 + " "); } out.println(); } } public static void main(String[] args) throws Exception { new Example().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
def main(n): if n <= 2: return "-1" l = list(reversed(list(range(1, n + 1)))) return ' '.join(list(map(str, l))) print(main(int(input())))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n < 3: print(-1) else: 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 con1 { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n =sc.nextInt(); if(n<3){ System.out.println(-1); }else while(n>0){ System.out.print(n+" "); 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
n = int(input()) if n <= 2: 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)(raw_input()); if (n < 3): print -1; else: for i in range(n): print n - i,; print '\n';
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.*; public class p246A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.close(); if(n < 3) 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
n = input() if n <= 2: print -1 else: alist = [2, 3] alist.extend([1] * (n - 2)) print " ".join(map(str, alist))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.FileNotFoundException; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in;//new FileInputStream("input.txt"); OutputStream outputStream = System.out;//new FileOutputStream("output.txt"); InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ////////////////////////////////////////////////////////////////////////////// TaskC solver = new TaskC(); solver.solve(in, out); ////////////////////////////////////////////////////////////////////////////// out.close(); } static class TaskC { void solve(InputReader in, PrintWriter out) { int n; n = in.nextInt(); if(n<=2) out.println(-1); else { for(int i=n; i>0; i--) out.print(i + " "); out.println(); } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next() { while(tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch(IOException e) { e.printStackTrace(); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { String str = ""; try { str = reader.readLine(); } catch(IOException e) { e.printStackTrace(); } return str; } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
a = int(input()) d = 4 if a == 1 or a == 2 : print(-1) else: for i in range(a -1): print(d ,end = " ") d += 1 print(1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long int n; cin >> n; if (n <= 2) { cout << "-1"; return 0; } for (long long int i = n; i > 0; i--) cout << i << " "; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.util.Arrays; import java.util.Scanner; public class _0560BuggySorting { static void sort(int[] arr) { int n=arr.length; for(int i=0;i<n-1;i++) { for(int j=0;j<n-i-1;j++) { if(arr[j]>arr[j+1]) { int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } System.out.println(Arrays.toString(arr)); } public static void main(String[] args) { // sort(new int[] {8,3,1,7}); Scanner sc = new Scanner(System.in); int n=sc.nextInt(); if(n<=2) { System.out.println(-1); } else { int st=n; for(int i=0;i<n;i++) { System.out.print(st+" "); st--; } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
def readarray(f): return map(f, raw_input().split()) def readint(): return int(raw_input()) def printlist(l): print ' '.join(map(str, l)) n = readint() if n < 3: print -1 else: printlist([3, 2, 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
print [n<=2 and -1 or ' '.join(map(str,range(n,0,-1))) for n in [int(raw_input())]][0]
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) if n <= 2: print("-1") else: 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
#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 >= 1; i--) { cout << 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; int x = n; if (n <= 2) cout << -1 << endl; else { for (int i = 0; i < n; i++) { arr[i] = x; x--; } for (int i = 0; i < n; i++) cout << arr[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(void) { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { arr[i] = i + 1; } reverse(arr, arr + n); if (n < 3) cout << -1 << "\n"; else { for (auto u : arr) cout << u << " "; 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.io.*; import java.lang.reflect.Field; import java.math.BigInteger; import java.util.*; public class codeforces implements Runnable { private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringTokenizer(""); public static void main(String[] args) { new Thread(new codeforces()).run(); } public void run() { /* * try { // br = new BufferedReader(new * FileReader("input.txt")); pw = new * PrintWriter("output.txt"); } catch * (FileNotFoundException e) { e.printStackTrace(); } */ 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("KaVaBUnGO!!!", 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()); } String nextLine() { try { return br.readLine(); } catch (IOException e) { } return null; } private void solver() { int n = ni(); if (n<3){ System.out.println(-1); }else { for(int i=n; i>=1; i--){ System.out.print(i+" "); } } } private BigInteger nbi() { return new BigInteger(nstr()); } 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 sys n = input() if(n <= 2): print -1 else: a = range(n, 0, -1) for i in xrange(n): if(i!= 0): sys.stdout.write(" ") sys.stdout.write(str(a[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 <= 2: print -1 else: print ' '.join(map(str, xrange(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 sys import math import string from collections import deque # Function # def read_int() : temp = raw_input().split(); return map(int, temp); def read_str() : temp = raw_input().split(); return temp; def write(output) : sys.stdout.write(output); def writeln(output) : sys.stdout.write(str(output)+'\n'); # Class # INF = 9123456789123456789 # Main Entry # # Inner Function # ans = set(); if __name__ == '__main__': n = read_int()[0]; if n <= 2 : print -1; else : strout = "" for ii in xrange(n, 0, -1) : strout+=str(ii)+" "; print strout[0:-1]; pass # End Here #
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, i; scanf("%d", &n); if (n < 3) printf("-1\n"); else { printf("%d %d", n - 1, n); for (i = 1; i <= n - 2; i++) printf(" %d", i); printf("\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int ( raw_input() ) if n <= 2: print -1 else: a = ['2'] * (n-1) + ['1'] print ' '.join(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=input() if n>2: print ' '.join(map(str,range(n,0,-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
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n > 2){ for (int i = 2; i <= n; ++i) { System.out.println(i + " "); } System.out.println(1); }else { System.out.println(-1); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class Main { static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { int n = in.nextInt(); if(n < 3) out.print(-1); else for(int i = n; i > 0; i--) out.print(i + " "); out.close(); } static class Scanner { BufferedReader br; StringTokenizer st; public Scanner() { br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } public String next() throws IOException { if(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public String nextLine() throws IOException { if(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); String r = st.nextToken("\n"); st = new StringTokenizer(br.readLine(), " "); return r; } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n = int(input()) a = list(map(str,list(range(n,0,-1)))) if n <= 2: print (-1) else: print (" ".join(a))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
n=int(input()) if n<3:print(-1) else: 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
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, l, m, n, p, q, a, b, c, d, x, y, z, t, ans = 0; int arr[200006]; cin >> n; if (n == 1 || 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
n = int(input()) if n < 3: print(-1) else: arr = [2,3,1] for i in range(4,n+1): arr.append(i) print(*arr)
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; long long int max(long long int a, long long int b) { if (a >= b) return a; else return b; } long long int min(long long int a, long long int b) { if (a >= b) return b; else return a; } long long int diff(long long int a, long long int b) { if (a >= b) return a - b; else return b - a; } void pairsort(int a[], int b[], int n) { pair<int, int> pairt[n]; for (int i = 0; i < n; i++) { pairt[i].first = a[i]; pairt[i].second = b[i]; } sort(pairt, pairt + n); for (int i = 0; i < n; i++) { a[i] = pairt[i].first; b[i] = pairt[i].second; } } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; if (n == 1 || n == 2) cout << -1; else { for (int i = n; i > 0; i--) cout << i << " "; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a. loop integer variable i from 1 to n - 1     loop integer variable j from i to n - 1         if (aj > aj + 1), then swap the values of elements aj and aj + 1 But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1. Input You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array. Output Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1. If there are several counter-examples, consisting of n numbers, you are allowed to print any of them. Examples Input 1 Output -1
2
7
import java.io.File; import java.util.Formatter; import java.util.Scanner; // In the name of The Friend // CONTEST TEMPLATE ---- SmileToAzrael ......... bagherbal /** * * @author ali */ public class A { public static void main(String[] args) { try { Scanner input = new Scanner(System.in); int n = input.nextInt(); if (n <= 2) { System.out.println("-1"); } else { System.out.print("2 2"); for (int i = 2; i < n; i++) System.out.print(" 1"); System.out.println(""); } System.exit(0); } catch(Exception e) { e.printStackTrace(); } } }
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 v[1000000]; int buggy_sorting(int n) { if (n == 1 || n == 2) return 0; v[0] = 5; v[1] = 6; v[2] = 1; for (int i = 3; i < n; i++) v[i] = i; return 1; } void median() { int t, n, k, pas, cnt; long long int s; cin >> t; for (int z = 0; z < t; z++) { cin >> n >> k; pas = n / 2; for (int i = 0; i < n * k; i++) cin >> v[i]; cnt = 0; s = 0; for (int i = n * k - 1 - pas; i >= 0; i -= pas + 1) if (cnt < k) { s += v[i]; cnt++; } cout << s << '\n'; } } int main() { int n; cin >> n; if (buggy_sorting(n)) for (int i = 0; i < n; i++) cout << v[i] << " "; else cout << -1; return 0; }
CPP