Search is not available for this dataset
name
stringlengths 2
112
| description
stringlengths 29
13k
| source
int64 1
7
| difficulty
int64 0
25
| solution
stringlengths 7
983k
| language
stringclasses 4
values |
---|---|---|---|---|---|
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n<=2:
print(-1)
else:
print(*[n-x for x in range(n)]) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class BuggySorting {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
if(n==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 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if ( n<=2 ) {
System.out.println(-1);
} else {
for ( int i = n ; i>=1 ; --i ) {
System.out.print(i+" ");
}
System.out.println();
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class AUnsuccessfulSorting {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int inputByte=sc.nextInt();
if(inputByte<3) {
System.out.print(-1);
}
else {
for(int i=inputByte; i>0; i--){
System.out.print(" "+i);
}
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
inline int ADD(int a, int b) {
a += b;
if (a >= 1000000007) a -= 1000000007;
return (int)a;
}
inline void ADDTO(int &a, int b) {
a += b;
if (a >= 1000000007) a -= 1000000007;
}
inline void SUBTO(int &a, int b) {
a -= b;
if (a < 0) a += 1000000007;
}
inline int MUL(int a, int b) { return (int)((long long)a * b % 1000000007); }
int main() {
int n;
while (scanf("%d", &n) == 1) {
if (n <= 2)
puts("-1");
else {
printf("3 2 1");
for (int i = 0; i < (n - 3); ++i) printf(" 1");
puts("");
}
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n < 3) {
cout << -1 << endl;
return 0;
}
cout << 5 << " " << 6 << " " << 4 << " ";
for (i = 1; i <= n - 3; i++) cout << 5 << " ";
cout << endl;
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.io.*;
import java.util.*;
public class cikk
{
static class InputReader {
private InputStream stream;
private byte[] inbuf = new byte[1024];
private int start= 0;
private int end = 0;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int readByte() {
if (start == -1) throw new UnknownError();
if (end >= start) {
end= 0;
try {
start= stream.read(inbuf);
} catch (IOException e) {
throw new UnknownError();
}
if (start<= 0) return -1;
}
return inbuf[end++];
}
private boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
private int skip() {
int b;
while ((b = readByte()) != -1 && isSpaceChar(b)) ;
return b;
}
public String next() {
int b = skip();
StringBuilder sb = new StringBuilder();
while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public int nextInt() {
int num = 0, b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
public long nextLong() {
long num = 0;
int b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
}
public static void main(String args[])
{
InputReader sc=new InputReader(System.in);
int n=sc.nextInt();
if(n!=1 && n!=2)
for(int i=n;i>=1;i--)
System.out.print(i+" ");
else
System.out.println(-1);
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n < 3:
print(-1)
else:
print(' '.join(str(i) for i in range(n, 0, -1)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print("-1")
else:
print(*list(range(n, 0, -1)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n<3:
print(-1)
else:
a=[i+1 for i in range(n)]
a=sorted(a,reverse=True)
for b in a:
print b, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class CF246taskA {
StringTokenizer st;
BufferedReader in;
PrintWriter out;
public static void main(String[] args) throws NumberFormatException,
IOException {
CF246taskA solver = new CF246taskA();
solver.open();
long time = System.currentTimeMillis();
solver.solve();
if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
System.out.println("Spent time: "
+ (System.currentTimeMillis() - time));
System.out.println("Memory: "
+ (Runtime.getRuntime().totalMemory() - Runtime
.getRuntime().freeMemory()));
}
solver.close();
}
public void open() throws IOException {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
public String nextToken() throws IOException {
while (st == null || !st.hasMoreTokens()) {
String line = in.readLine();
if (line == null)
return null;
st = new StringTokenizer(line);
}
return st.nextToken();
}
public int nextInt() throws NumberFormatException, IOException {
return Integer.parseInt(nextToken());
}
public long nextLong() throws NumberFormatException, IOException {
return Long.parseLong(nextToken());
}
public double nextDouble() throws NumberFormatException, IOException {
return Double.parseDouble(nextToken());
}
public void solve() throws NumberFormatException, IOException {
int n = nextInt();
if (n<3) {
out.println(-1);
return;
}
out.print("3 2 1 ");
for (int i = 4; i <= n; i++) {
out.print(i+" ");
}
}
public void close() {
out.flush();
out.close();
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long int n;
cin >> n;
if (n < 3) {
cout << -1;
return 0;
}
long long int a[n];
a[0] = n;
a[1] = n;
for (long long int I = 2; I < n; I += 1) a[I] = I;
for (long long int I = 0; I < n; I += 1) cout << a[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 sys
import math
#import random
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
return(int(input()))
def inara():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############
n=inp()
if n<=2:
print(-1)
else:
for i in range(n,0,-1):
print(i,end=" ")
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
n = int(sys.stdin.readline().strip())
if n < 3:
print(-1)
else:
print(' '.join([str(n-i) for i in range(0, n)]))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n < 3)
cout << "-1\n";
else {
for (i = n; i > 1; i--) cout << i << " ";
cout << "1" << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | def main():
n = int(raw_input())
if n < 3:
print -1
return
print ' '.join(map(str, list(reversed(xrange(1, n + 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())
print(-1 if n<=2 else "2 3 "+"1 "*(n-2))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n > 2:
print " ".join(map(str, reversed(range(1, n + 1))))
else:
print "-1"
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
/**
* Works good for CF
* @author cykeltillsalu
*/
public class A {
//some local config
static boolean test = false;
static String testDataFile = "testdata.txt";
static String feedFile = "feed.txt";
CompetitionType type = CompetitionType.CF;
private static String ENDL = "\n";
// solution
private void solve() throws Throwable {
int n = iread();
if( n > 2){
for (int i = 0; i < n-1; i++) {
System.out.print((n - i) + " ");
}
System.out.println("1");
} else {
System.out.println("-1");
}
}
public int iread() throws Exception {
return Integer.parseInt(wread());
}
public double dread() throws Exception {
return Double.parseDouble(wread());
}
public long lread() throws Exception {
return Long.parseLong(wread());
}
public String wread() throws IOException {
StringBuilder b = new StringBuilder();
int c;
c = in.read();
while (c >= 0 && c <= ' ')
c = in.read();
if (c < 0)
return "";
while (c > ' ') {
b.append((char) c);
c = in.read();
}
return b.toString();
}
public static void main(String[] args) throws Throwable {
if(test){ //run all cases from testfile:
BufferedReader testdataReader = new BufferedReader(new FileReader(testDataFile));
String readLine = testdataReader.readLine();
int casenr = 0;
out: while (true) {
BufferedWriter w = new BufferedWriter(new FileWriter(feedFile));
if(!readLine.equalsIgnoreCase("input")){
break;
}
while (true) {
readLine = testdataReader.readLine();
if(readLine.equalsIgnoreCase("output")){
break;
}
w.write(readLine + "\n");
}
w.close();
System.out.println("Answer on case "+(++casenr)+": ");
new A().solve();
System.out.println("Expected answer: ");
while (true) {
readLine = testdataReader.readLine();
if(readLine == null){
break out;
}
if(readLine.equalsIgnoreCase("input")){
break;
}
System.out.println(readLine);
}
System.out.println("----------------");
}
testdataReader.close();
} else { // run on server
new A().solve();
}
out.close();
}
public A() throws Throwable {
if (test) {
in = new BufferedReader(new FileReader(new File(feedFile)));
}
}
InputStreamReader inp = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(inp);
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
enum CompetitionType {CF, OTHER};
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.util.Scanner;
public class buggysorting {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
if (n<3)
{
System.out.print(-1);
}
else
{
for (int i=n; i>0; i--)
{
System.out.print(i);
System.out.print(" ");
}
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3)
cout << -1 << endl;
else {
for (int i = n; i >= 2; i--) cout << i << " ";
cout << 1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class Solver {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int 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(input())
if n < 3:
print(-1)
else:
while n > 0:
print(n, end=" ")
n -= 1 | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
ios_base::sync_with_stdio(false);
cin >> n;
if (n < 3) {
cout << "-1";
return 0;
}
for (int i = n; i >= 1; i--) cout << i << ' ';
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | from sys import stdin
n=int(stdin.readline())
if n==1 or n==2:
print("-1")
else:
print("2 3 1",end=" ")
for i in range(4,n+1):
print(i,end=" ")
print() | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n < 3:
print -1
exit()
for i in xrange(1, n + 1):
if i == 1:
print 2,
elif i == 2:
print 3,
elif i == 3:
print 1,
else:
print i, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2)
cout << -1;
else {
for (int i = 2; i <= n; i++) cout << i << " ";
cout << 1;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n==1 or n==2:
print "-1"
else:
while n>0:
print n,
n-=1 | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n <= 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 | #include <bits/stdc++.h>
using namespace std;
unsigned long long n = 0, m = 100, i, j, k, ans = -1, y, x, z, l, a, b, c, s,
o = 0;
bool can = false;
int main() {
std::ios_base::sync_with_stdio(false);
cin >> n;
if (n < 3)
cout << -1;
else
while (n--) cout << n + 1 << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) {
cout << "-1\n";
return 0;
}
cout << "2 3";
for (int i = 1; i <= n - 2; ++i) {
cout << " 1";
}
cout << '\n';
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | def stripped_line():
return raw_input().strip()
def read_ints():
return map(int, stripped_line().split())
n = read_ints()[0]
if n <= 2:
print -1
else:
res = range(1, n + 1)
res.reverse()
print " ".join([str(x) for x in res])
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | X = int(input())
print("".join([str(i) + " " for i in range(X, 0, -1)]) if X > 2 else -1)
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if (n <= 2):
print("-1")
else:
for i in range(2, n + 1):
print(str(i) + " ")
print("1\n") | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, ret;
while (cin >> n) {
if (n == 1 || n == 2)
cout << -1 << endl;
else {
int cnt = 0;
for (int i = n; i >= 1; i--) {
if (cnt) cout << " ";
cnt++;
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
if (n < 3)
cout << -1 << "\n";
else {
for (int i = n; i > 0; i--)
if (i == 1)
cout << i << "\n";
else
cout << i << " ";
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n < 3:
print -1
exit()
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 | n = int(input())
if n <= 2:
print(-1)
else:
print(' '.join(str(2 - x // (n - 1)) for x in range(n)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if(n <= 2):
print(-1)
else:
arr = list(range(1, n + 1))
arr.reverse()
arr = [str(i) for i in arr]
print(" ".join(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>
int main() {
int n, i;
scanf("%d", &n);
if (n == 1 || n == 2)
printf("-1\n");
else {
printf("3 2");
for (i = 3; i <= n; i++) printf(" 1");
printf("\n");
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()-2;
if n<1:
print -1
else:
print '2 3','1 '*n
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ar {
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;
}
}
public static void main(String[] args) throws java.lang.Exception {
FastReader scn = new FastReader();
int n=scn.nextInt();
if(n<3){
System.out.print(-1+"\n");
return;
}else{
System.out.print(7+" "+8+" ");
for(int i=1;i<=n-2;i++){
System.out.print(2+" ");
}
}
}
} | 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 bad_sort ():
n = int ( raw_input () )
if not (1 <= n <= 50): return -1
if (n < 3): print -1
else: print " ".join( map ( str, range (n,0,-1)) )
bad_sort () | 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;
void makra() {
int n;
cin >> n;
if (n <= 2)
cout << "-1\n";
else {
for (int i = 0; i < n; ++i) cout << n - i << " ";
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tc = 1;
while (tc--) {
makra();
}
cerr << "Time elapsed:" << clock() / (long double)CLOCKS_PER_SEC << "sec"
<< endl;
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
a = [n-i for i in range(n)]
def so(n, a):
for i in range(n-1):
for j in range(i, n-1):
a[j], a[j+1] = a[j+1], a[j]
if n in (1, 2):
print(-1)
else:
print(' '.join(map(str, 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 | import java.util.*;
import java.io.*;
public class A {
FastScanner in;
PrintWriter out;
public void solve() throws IOException {
int n = in.nextInt();
if (n <= 2) {
out.println(-1);
return;
}
for (int i = 0; i < n -1 ; i++) {
out.print(99 + " ");
}
out.println(1);
}
public void run() {
try {
in = new FastScanner(System.in);
out = new PrintWriter(System.out);
solve();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
FastScanner(File f) {
try {
br = new BufferedReader(new FileReader(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
FastScanner(InputStream in) {
br = new BufferedReader(new InputStreamReader(in));
}
String next() throws IOException {
return hasNext() ? st.nextToken() : null;
}
boolean hasNext() throws IOException {
while (st == null || !st.hasMoreTokens()) {
String line = br.readLine();
if (line == null) {
return false;
}
st = new StringTokenizer(line);
}
return true;
}
int nextInt() throws NumberFormatException, IOException {
return Integer.parseInt(next());
}
}
public static void main(String[] arg) {
new A().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;
int main() {
long n, i, mas[100], j, t;
cin >> n;
for (i = 0; i < n; ++i) mas[i] = n - i;
for (i = 0; i < n - 1; ++i)
for (j = i; j < n - 1; ++j)
if (mas[j] > mas[j + 1]) {
t = mas[j];
mas[j] = mas[j + 1];
mas[j + 1] = t;
}
for (i = 0; i < n - 1; ++i)
if (mas[i] > mas[i + 1]) {
for (j = 0; j < n; ++j) cout << n - j << ' ';
return 0;
}
cout << -1;
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #coding:utf-8
import sys
n = int(sys.stdin.readline())
if n > 2:
for a in range(n, 0, -1):
print a,
print
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.Scanner;
public class Prob246A {
public static void main(String[] Args) {
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
if (x <= 2)
System.out.println(-1);
else {
for (int i = 1; i < x; i++)
System.out.print((i + 1) + " ");
System.out.println(1);
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve(istream &in, ostream &out) {
int n;
in >> n;
if (n < 3) {
out << -1;
return;
}
for (int i = 0; i < n; ++i) out << n - i << " ";
}
int main() {
solve(cin, cout);
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(raw_input())
if n==1 or n==2: print -1
else:
for i in xrange(n):
print n-i,
print
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n<=2:
print('-1')
else:
s=''
for i in range(n,0,-1):
s+=str(i)+' '
print(s) | 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 sys
n=int(sys.stdin.readline())
a=[x for x in range(1,n+1)]
a.sort(reverse=True)
b=[str(x) for x in a]
if n<=2:
print -1
else:
print ' '.join(b) | 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 gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
}
template <class T>
inline T bigmod(T p, T e, T M) {
long long ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <typename T>
string NtoS(T Number) {
stringstream ss;
ss << Number;
return ss.str();
}
long long pow(long long x, long long y) {
long long res = 1;
for (; y;) {
if ((y & 1)) {
res *= x;
}
x *= x;
y >>= 1;
}
return res;
}
int main() {
int a, b, c, d, n, m, s[1001], t[100];
scanf("%d", &n);
for (int i = n; i >= 1; i--) {
s[n - i + 1] = i;
t[n - i + 1] = i;
}
for (int i = 1; i <= n - 1; i++) {
for (int j = i; j < n - 1; j++) {
if (s[j] > s[j + 1]) swap(s[j], s[j + 1]);
}
}
for (int i = 1; i <= n; i++) {
if (s[i] != t[i]) {
for (int i = 1; i <= n; i++) cout << t[i] << " ";
return 0;
}
}
cout << "-1";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1 || n == 2)
cout << -1 << endl;
else {
while (true) {
cout << n;
if (n != 1) cout << ' ';
n--;
if (n == 0) return 0;
}
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.text.*;
public class Main {
static long mod = 1000_000_007;
static long mod1 = 998244353;
static boolean fileIO = false;
static boolean memory = true;
static FastScanner f;
static PrintWriter pw;
static double eps = (double)1e-6;
static int oo = (int)1e7;
// N = 1 or N = max ?
// longs vs. ints ?
// max / min ?
public static void solve() throws Exception {
int n = f.ni();
int arr[] = new int[n];
if (n <= 2) {
pn(-1);
return;
}
for (int i = n; i >= 1; --i) p(i + " ");
}
public static void main(String[] args)throws Exception {
if(memory) new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();System.exit(1);}}}, "", 1 << 28).start();
else new Main().run();
}
/******************************END OF MAIN PROGRAM*******************************************/
void run()throws Exception {
if (System.getProperty("ONLINE_JUDGE") == null) {
f = new FastScanner("");
pw = new PrintWriter(System.out);
}
else {
f = new FastScanner();
pw = new PrintWriter(System.out);
//fw = new FileWriter("!out.txt");
}
//pre();
int t = 1;
int tt = 1;
while(t --> 0) {
//fw.write("Case #" + (tt++) + ": ");
//fw.write("\n");
solve();
}
pw.flush();
pw.close();
}
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(String str) throws Exception {
try {
br = new BufferedReader(new FileReader("!a.txt"));
}
catch (Exception e) {
e.printStackTrace();
}
}
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public String next()throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int ni() throws IOException {return Integer.parseInt(next());}
public long nl() throws IOException {return Long.parseLong(next());}
public String nextLine() throws IOException {return br.readLine();}
public double nd() throws IOException {return Double.parseDouble(next());}
}
public static void pn(Object... o) {for(int i = 0; i < o.length; ++i) pw.print(o[i] + (i + 1 < o.length ? " ": "\n"));}
public static void p(Object... o) {for(int i = 0; i < o.length; ++i) pw.print(o[i] + (i + 1 < o.length ? " " : ""));}
public static void pni(Object... o) {for(Object obj : o) pw.print(oo + " "); pw.println(); pw.flush();}
public static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
public static long gcd(long a,long b){if(b==0l)return a;else{return gcd(b,a%b);}}
public static long lcm(long a,long b){return (a*b/gcd(a,b));}
public static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
public static int pow(int a,int b){int res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
public static long mpow(long a,long b, long m){long res=1;while(b>0){if((b&1)==1)res=((res%m)*(a%m))%m;b>>=1;a=((a%m)*(a%m))%m;}return res;}
public static long mul(long a , long b , long mod){return ((a%mod)*(b%mod)%mod);}
public static long adp(long a , long b){return ((a%mod)+(b%mod)%mod);}
public static int dig(long a){int cnt=0;while(a>0){a/=10;++cnt;}return Math.max(1,cnt);}
public static int dig(int a){int cnt=0;while(a>0){a/=10;++cnt;}return Math.max(1,cnt);}
public static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
public static boolean isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
public static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
public static HashSet<Integer> factors(int n){HashSet<Integer> hs=new HashSet<Integer>();for(int i=1;i<=(int)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
public static HashSet<Long> pf(long n){HashSet<Long> ff=factors(n);HashSet<Long> ans=new HashSet<Long>();for(Long i:ff)if(isPrime(i))ans.add(i);return ans;}
public static HashSet<Integer> pf(int n){HashSet<Integer> ff=factors(n);HashSet<Integer> ans=new HashSet<Integer>();for(Integer i:ff)if(isPrime(i))ans.add(i);return ans;}
public static int gnv(char c){return Character.getNumericValue(c);}
public 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);}
public 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);}
public static void sort(ArrayList<Integer> a){Collections.sort(a);}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (~scanf("%d", &n)) {
if (n <= 2)
printf("-1\n");
else {
int flag = 2;
for (int i = n; i != 1; i--) {
while (flag) {
printf("%d ", i);
flag--;
if (flag == 0) i--;
}
printf("%d ", i);
}
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 | import math
def solve(n):
if n <= 2:
return [-1]
return [i for i in range(n,0,-1)]
def main() :
n = int(input())
# arr = list(map(int, input().split(' ')))
# arr = []
# for _ in range(3):
# arr.append(input())
print(*solve(n))
main()
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
import java.io.*;
public class Buggy_Sorting
{
public static void main(String args[]) throws Exception
{
BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
int size=Integer.parseInt(f.readLine());
if(size<=2)
System.out.println(-1);
else
{
for(int x=size;x>=1;x--)
System.out.print(x+" ");
System.out.println();
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
#my_file = sys.stdin
#my_file = open("input.txt", "r")
n = int(input())
if n > 2:
lst = list(range(n-1,0,-1))
lst.insert(0, n-1)
for i in lst:
print(i, end=" ")
else:
print(-1) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if (n <= 2):
print(-1)
else:
for i in range(n - 1, -1, -1):
print(i + 1, 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 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner Sc=new Scanner(System.in);
int n=Sc.nextInt();
if(n<=2)
System.out.println(-1);
else
{
for(int i=n;i>=1;i--)
System.out.print(i+" ");
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
if (a > 2) {
for (int i = a; i > 0; i--) cout << i << " ";
} else
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 | #July 4, 2014
sa=int(input())
string=''
if sa==1 or sa==2:
print("-1")
else:
for x in range(sa, 0, -1):
string+=str(x)
string+=' '
print(string.strip())
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if ( n <= 2 ) : print -1
else : print n-1,n,' '.join(map(str,range(1,n-1))) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
print(*[x for x in range(n, 0, -1)])
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
def RedirectIO():
sys.stdin=open("test.in","r")
# sys.stdout=open("output.txt","w")
#RedirectIO()
def main():
n=int(raw_input())
if n<3:
print -1
else:
for i in xrange(n,0,-1):
print i,
main()
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
if (n <= 2)
cout << -1;
else
while (n--) cout << n + 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 | n=int(raw_input())
if n<3:
print -1
else:
print " ".join(map(str,range(2,n+1)+[1])) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskA solver = new TaskA();
solver.solve(1, in, out);
out.close();
}
static class TaskA {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int[] arr = new int[n];
if (n == 1 || n == 2) {
out.println("-1");
return;
}
arr[0] = n;
arr[1] = n - 1;
for (int i = 2; i < n; ++i) {
arr[i] = n - i;
}
for (int i = 0; i < n; ++i) {
out.print(arr[i] + " ");
}
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class codeforce {
static Scanner sc = new Scanner(System.in);
//static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintStream out = new PrintStream(System.out);
//public static int mod = 1000000007;
public static void main(String[] args) throws IOException {
int n = sc.nextInt();
if (n<=2)out.println(-1);
else
for(int i=n;i>0;i--)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;
template <class T>
T Abs(T x) {
return x > 0 ? x : -x;
}
template <class T>
T Max(T a, T b) {
return a > b ? a : b;
}
template <class T>
T Min(T a, T b) {
return a < b ? a : b;
}
template <class T>
T gcd(T a, T b) {
return a % b == 0 ? b : gcd(b, a % b);
}
bool isVowel(char ch) {
ch = tolower(ch);
return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
int main() {
int i, j, k, n, tc;
while (cin >> n) {
if (n < 3) {
cout << -1 << endl;
continue;
}
cout << 3 << " " << 2 << " " << 1;
for (int i = (4); i < (n + 1); i++) cout << " " << i;
cout << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n;
int a[N];
int main() {
cin >> n;
if (n < 3) {
cout << -1;
return 0;
}
for (int i = 0; i < n; i++) a[i] = n - i;
for (int i = 0; i < n; i++) cout << a[i] << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class p222
{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter wf = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
if(n > 2 ){
for(int i = 2; i <= n ; i++ ){
wf.write(i + " ");
}
wf.write("1");
}else{
wf.write("-1");
}
wf.newLine();
wf.flush();
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n < 3:
print(-1)
else:
print(2, 2, *([1] * (n - 2))) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Steve Phillips / elimisteve
# 2012.11.21
n = int(raw_input())
#array = [2, 1, 3, 9, 8, 7, 7, 8, 3, 2, 3]
if n <= 2:
print -1
else:
print 2, 3,
for _ in xrange(n-2):
print 1,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.util.*;
import java.math.*;
public class main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
if(n<=2){System.out.println("-1");return ;}
int [] array = new int[n+1];
for(int i=1 ; i<=n ; i++)
{
array[i]=n-i+1;
}
for(int i=1 ; i<n ; i++)
{
for(int j=i ; j<n ; j++)
if(array[j]>array[j+1])
{
int tmp=array[j];
array[j]=array[j+1];
array[j+1]=tmp;
}
}
Arrays.sort(array);
System.out.printf("%d", array[n]);
for(int i=n-1 ; i>=1 ; i--) System.out.printf(" %d",array[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:
while n > 0:
print(n, end=' ')
n -= 1
# CodeForcesian
# ♥
# اگه ایمان داری که روزای خوب تو راهن
# روزای خوب قطعا به سمتت میاد
| 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(map(str, range(n, 0, -1))))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, n;
int main() {
cin >> n;
if (n == 1 || n == 2) {
cout << "-1\n";
return 0;
}
cout << "2\n";
for (i = n; i >= 1; --i) {
if (i != 2) cout << i << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print(-1)
else:
for i in range(n, 0, -1):
print(i, end = ' ') | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class BuggySorting {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n == 1||n==2) {
System.out.println(-1);
} else {
for (int i = 0; i < n; i++) {
System.out.print(n - i + " ");
}
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) {
cout << "-1";
return 0;
}
for (int i = n; i >= 1; i--) cout << i << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class prog {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int asd=scan.nextInt();
if(asd<=2){
System.out.println(-1);
}
else{
System.out.print(4+" ");
System.out.print(5+" ");
System.out.print(3+" ");
for (int i = 0; i < asd-3; i++) {
System.out.print((i+1)+" ");
}
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n < 3 :
print(-1)
exit()
for i in range(n, 0, -1):
print(i, end = ' ')
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class p246a
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n == 1 || n == 2)
cout << -1;
else
cout << 5 << " " << 4 << " " << 2 << " ";
for (i = 0; i < n - 3; 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 | #include <bits/stdc++.h>
int main() {
int i, n;
scanf("%d", &n);
if (n <= 2)
printf("-1\n");
else
for (i = n; i >= 1; i--) printf("%d ", i);
return (0);
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n>2:
for i in range(n,0,-1):
print(i, end=' ')
else:
print(-1) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Solution {
public static final int MOD = 1000050131;
public static void main(String args[]) throws IOException {
// BufferedReader br = new BufferedReader(new FileReader("c://tmp//in.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = r_i(br);
if (n > 2) {
// int a[] = new int[n];
for (int i = n; i >= 1; i--) {
pr_o(i + " ");
// a[n - i] = i;
}
/*
* pr_o_nl(Arrays.toString(a)); for (int i = 1; i < n; i++) { for (int j = i; j
* < n; j++) { int tmp = a[i]; a[i] = a[j]; a[j] = tmp; } }
* pr_o_nl(Arrays.toString(a));
*/
} else {
pr_o(-1);
}
}
public static void pr_o(Object s) {
System.out.print(s);
}
public static void pr_o_nl(Object s) {
System.out.print(s);
pr_nl();
}
public static void pr_nl() {
System.out.println();
}
public static int prs_s_i(String s) {
return Integer.parseInt(s);
}
public static Long prs_s_l(String s) {
return Long.parseLong(s);
}
public static int r_i(BufferedReader br) throws IOException {
return prs_s_i(br.readLine());
}
public static long r_l(BufferedReader br) throws IOException {
return prs_s_l(br.readLine());
}
public static String r_s(BufferedReader br) throws IOException {
return br.readLine();
}
public static String[] r_s_a(BufferedReader br) throws IOException {
return br.readLine().split(" ");
}
public static int[] r_i_a(BufferedReader br) throws IOException {
String s[] = r_s_a(br);
int a[] = new int[s.length];
for (int i = 0; i < s.length; i++) {
a[i] = prs_s_i(s[i]);
}
return a;
}
public static long[] r_l_a(BufferedReader br) throws IOException {
String s[] = r_s_a(br);
long a[] = new long[s.length];
for (int i = 0; i < s.length; i++) {
a[i] = prs_s_l(s[i]);
}
return a;
}
public static int[][] r_s_a_i(BufferedReader br, int a[][], int i) throws IOException {
String s1[] = r_s_a(br);
for (int j = 0; j < s1.length; j++) {
a[i][j] = prs_s_i(s1[j]);
}
return a;
}
public static int[][] r_s_a_r_w_o_s(BufferedReader br, int a[][], int r) throws IOException {
for (int i = 0; i < r; i++) {
String s = r_s(br);
for (int j = 0; j < r; j++) {
if (s.charAt(j) == '.') {
a[i][j] = 0;
} else {
a[i][j] = Integer.parseInt("" + s.charAt(j));
}
}
}
return a;
}
public static int[][] r_s_a_r(BufferedReader br, int a[][], int r) throws IOException {
for (int i = 0; i < r; i++) {
a = r_s_a_i(br, a, i);
}
return a;
}
public static Integer maxx(Integer... x) {
int max = 0;
for (Integer a : x) {
max = Math.max(a, max);
}
return max;
}
public static Integer minn(Integer... x) {
int min = Integer.MAX_VALUE;
for (Integer a : x) {
min = Math.min(a, min);
}
return min;
}
public static Long maxx(Long... x) {
long max = 0;
for (Long a : x) {
max = Math.max(a, max);
}
return max;
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3)
cout << "-1";
else
while (n > 0) cout << n-- << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n > 2) {
for (int i = 2; i <= n; i++) {
cout << i << " ";
}
cout << 1 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) return cout << -1, 0;
for (int i = 0; i < n - 1; i++) cout << 2 << " ";
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1 || n == 2)
cout << -1 << endl;
else {
cout << n;
for (int i = n - 1; i >= 1; i--) cout << " " << i;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
fast();
int n;
cin >> n;
if (n > 2) {
for (int i = 2; i <= n; ++i) {
cout << i << " ";
}
cout << 1 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(raw_input())
if(n<=2):
print -1
else:
print 99,100,98,
for i in range(n-3):
print i+1,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int n = in.nextInt();
if (n > 2) {
for (int i=0;i<n;i++) {
out.print((n-i) + " ");
}
} else {
out.println(-1);
}
out.flush();
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #!/usr/bin/python
n = input()
print ' '.join([`n-i` for i in xrange(n)]) 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 = int(raw_input())
if n < 3:
print "-1"
else:
for x in reversed(xrange(n)):
print x + 1, | PYTHON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.