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 | //package round151;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class A {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
if(n <= 2){
out.println(-1);
}else{
for(int i = n;i >= 1;i--){
if(i < n)out.print(" ");
out.print(i);
}
out.println();
}
}
void run() throws Exception
{
is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
long s = System.currentTimeMillis();
solve();
out.flush();
tr(System.currentTimeMillis()-s+"ms");
}
public static void main(String[] args) throws Exception
{
new A().run();
}
public int ni()
{
try {
int num = 0;
boolean minus = false;
while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
if(num == '-'){
num = 0;
minus = true;
}else{
num -= '0';
}
while(true){
int b = is.read();
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
}
} catch (IOException e) {
}
return -1;
}
public long nl()
{
try {
long num = 0;
boolean minus = false;
while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
if(num == '-'){
num = 0;
minus = true;
}else{
num -= '0';
}
while(true){
int b = is.read();
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
}
} catch (IOException e) {
}
return -1;
}
public String ns()
{
try{
int b = 0;
StringBuilder sb = new StringBuilder();
while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
if(b == -1)return "";
sb.append((char)b);
while(true){
b = is.read();
if(b == -1)return sb.toString();
if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
sb.append((char)b);
}
} catch (IOException e) {
}
return "";
}
public char[] ns(int n)
{
char[] buf = new char[n];
try{
int b = 0, p = 0;
while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
if(b == -1)return null;
buf[p++] = (char)b;
while(p < n){
b = is.read();
if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
buf[p++] = (char)b;
}
return Arrays.copyOf(buf, p);
} catch (IOException e) {
}
return null;
}
double nd() { return Double.parseDouble(ns()); }
boolean oj = System.getProperty("ONLINE_JUDGE") != null;
void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
| 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 | sz = int(input())
if sz < 3:
print (-1)
else:
print(*reversed([x+1 for x in range(sz)])) | 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() {
cin >> n;
if (n <= 2) {
printf("-1\n");
} else {
for (int i = 2; i <= n; i++) {
printf("%d ", i);
}
printf("1\n");
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #rOkY
#FuCk
################################ kOpAl ############################################
a=int(input())
if(a==1 or a==2):
print('-1')
else:
i=a
while(i>0):
print(i,end=' ')
i-=1
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a[100] = {0, 100, 99};
for (int i = 3; i <= 99; i++) a[i] = 1;
scanf("%d", &n);
if (n == 1 || n == 2)
printf("-1\n");
else {
for (int i = 1; i < n; i++) printf("%d ", a[i]);
printf("%d\n", a[n]);
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | def counterExample(n):
res = [i for i in range(1, n + 1)]
return " ".join(str(i) for i in reversed(res)) if n > 2 else -1
if __name__ == "__main__":
n = int(input())
print(counterExample(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.Scanner;
public class mainia {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int arraysize = 0;
Scanner sc = new Scanner(System.in);
arraysize = sc.nextInt();
if(arraysize <= 2){
System.out.println(-1);
}else{
for(int i=2; i<=arraysize; i++)
System.out.print(i + " ");
System.out.println(1);
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0;
cin >> n;
if (n <= 2)
cout << -1;
else
for (int i = n; i > 0; i--) cout << i << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
if (n <= 2) {
cout << -1 << endl;
return;
}
for (int i = n; i > 0; i--) {
cout << i << " ";
}
cout << "\n";
return;
}
int main() { solve(); }
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if n == 1 or n == 2 : print -1
else :
ans = []
for i in xrange(n) :
ans.append(n - i)
for i in xrange(n) :
print ans[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>
int scan() {
int t = 0;
char c;
c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
t = (t << 3) + (t << 1) + c - '0';
c = getchar();
}
return (t);
}
void go() {
int T = scan();
if (T < 3)
printf("-1");
else {
for (int i = T; i >= 1; i--) printf("%d ", i);
}
}
int main() {
go();
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n == 1 || n == 2) {
cout << -1;
} else
for (i = n; i >= 1; i--) cout << i << " ";
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | a = int(raw_input())
if(a<3):
print "-1"
exit()
for i in range(a,a/2,-1):
print i,
for i in range(1,a/2+1):
print i,
"""
Tester Function
raw_input()
b = map(int,raw_input().split())
for i in range(len(b)-1):
for j in range(i,len(b)-1):
if(b[j]>b[j+1]):
b[j], b[j+1] = b[j+1], b[j]
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.util.*;
import java.io.*;
public class Solution {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
String nextToken() throws Exception {
while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
return st.nextToken();
}
int nextInt() throws Exception {
return Integer.parseInt(nextToken());
}
void solve() throws Exception {
int n = nextInt();
if (n < 3) out.println(-1); else {
for (int i = n; i > 0; i--) out.print(i + " ");
}
}
void run() {
try {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
solve();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
} finally {
out.close();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Solution().run();
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = raw_input()
n = int(n)
if n>2:
for x in xrange(n+1,1,-1):
print x,
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 | /* package whatever; // 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 Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner scan=new Scanner(System.in);
int n=scan.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 | n = int(raw_input().strip())
if n in (1, 2):
print -1
else:
print ' '.join(map(str, range(n, 0, -1))) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Jose
*/
import java.util.Scanner;
public class Buggy {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int num=in.nextInt();
if(num==1 || num==2)
{
System.out.println(-1);
}else
{
String a="";
for (int i = num; i >0; i--) {
a+=i+" ";
}
System.out.println(a.trim());
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
if (n <= 2) {
puts("-1");
} else {
printf("2 3 1");
for (int i = 4; i <= n; 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 | n=input()
if(n<3):
print "-1"
else:
for i in xrange(n,0,-1):
print i, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n > 2:
print(*range(n, 0, -1))
else:
print(-1)
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | x=int(raw_input())
if x<3:
print -1
else:
for i in range(x,0,-1):
print i
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class BuggySorting {
public static void main(String[]args){
Scanner sc=new Scanner (System.in);
int n=sc.nextInt();
int []arr=new int [n];
int c=n;
if(n==1 || n==2)
System.out.println(-1);
else{
for(int i=0;i<n;i++) {
arr[i] = c;
c--;
}
for(int j=0;j<n;j++)
System.out.print(arr[j]+" ");
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n < 3:
print -1
else:
ans = ''
for i in range(n, 0, -1):
ans += str(i) + ' '
print ans[:-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.lang.*;
import java.io.*;
import java.util.*;
public class Sorting {
public static void main(String[] args) throws java.lang.Exception {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskA solver = new TaskA();
solver.solve(in, out);
out.close();
}
}
class TaskA {
public void solve(InputReader in, PrintWriter out) {
int n = in.nextInt();
if (n <= 2) {
out.println(-1);
} else {
out.print("3 2 1");
for (int i=4; i<=n; ++i)
out.print(" " + i);
out.println();
}
}
}
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());
}
public long nextLong() {
return Long.parseLong(next());
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.awt.datatransfer.StringSelection;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
public class A {
static Scanner in; static int next() throws Exception {return in.nextInt();};
// static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
// static BufferedReader in;
static PrintWriter out;
public static void main(String[] args) throws Exception {
in = new Scanner(System.in);
// in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
// in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
int n = next();
if (n == 1|| n == 2) out.println("-1");
else for (int i = 0;i < n;i++) out.print(n-i + " ");
out.println();
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;
const int N = 400 + 5;
const int inf = 0x3f3f3f3f;
int main() {
int n;
cin >> n;
if (n <= 2)
puts("-1");
else {
for (int i = n; i; i--) {
cout << i << " \n"[i == 1];
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.PrintWriter;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
if(n == 1 || n == 2) {
out.println(-1);
} else {
out.print(n-1 + " ");
out.print(n);
for (int i = 1; i < n-1; i++) {
out.print(" " + i);
}
}
out.flush();
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (cin >> n) {
if (n <= 2)
cout << -1 << endl;
else
for (int i = n; i >= 1; i--) cout << i << " ";
cout << 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(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
if (n == 1 || n == 2) {
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 | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.TreeMap;
import java.util.TreeSet;
public class Tester
{
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n=ni();
if(n==1||n==2) {
out.println(-1);
return;
}
for(int i=n;i>=1;i--) {
out.print(i+" ");
}
}
void run() throws Exception
{
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
long s = System.currentTimeMillis();
solve();
out.flush();
if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
}
public static void main(String[] args) throws Exception
{ new Tester().run(); }
private byte[] inbuf = new byte[1024];
public int lenbuf = 0, ptrbuf = 0;
private int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf)
{
ptrbuf = 0;
try
{ lenbuf = is.read(inbuf); }
catch (IOException e)
{ throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private boolean isSpaceChar(int c)
{ return !(c >= 33 && c <= 126); }
private int skip()
{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private double nd()
{ return Double.parseDouble(ns()); }
private char nc()
{ return (char)skip(); }
private String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b)))
{ // when nextLine, (isSpaceChar(b) && b != ' ')
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b)))
{
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private int ni()
{
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();
}
}
private long nl()
{
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();
}
}
private static void tr(Object... o)
{ System.out.println(Arrays.deepToString(o)); }
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
print -1 if n<3 else ' '.join(map(str, range(2, n+1)+[1]))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2)
cout << -1 << endl;
else {
for (int i = n; i != 0; i--) cout << i << " ";
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n<=2:
print(-1)
else:
for i in range(n,0,-1):
print(i),
print('') | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n>2:
for i in range(n):
print(n-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.util.*;
public class PA {
public static void main(String[] args) {
new PA().run();
}
private void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n <= 2) {
System.out.println(-1);
return;
}
System.out.print("2 2");
for (int i = 0; i < n - 2; i++) System.out.print(" 1");
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class A>
void read(vector<A>& v);
template <class A, size_t S>
void read(array<A, S>& a);
template <class T>
void read(T& x) {
cin >> x;
}
void read(double& d) {
string t;
read(t);
d = stod(t);
}
void read(long double& d) {
string t;
read(t);
d = stold(t);
}
template <class H, class... T>
void read(H& h, T&... t) {
read(h);
read(t...);
}
template <class A>
void read(vector<A>& x) {
for (auto& a : x) read(a);
}
template <class A, size_t S>
void read(array<A, S>& x) {
for (auto& a : x) read(a);
}
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return string(s); }
string to_string(string s) { return s; }
string to_string(vector<bool> v) {
string res;
for (int i = (0); (1) > 0 ? i < ((int)v.size()) : i > ((int)v.size());
i += (1))
res += char('0' + v[i]);
return res;
}
template <size_t S>
string to_string(bitset<S> b) {
string res;
for (int i = (0); (1) > 0 ? i < (S) : i > (S); i += (1))
res += char('0' + b[i]);
return res;
}
template <class T>
string to_string(T v) {
bool f = 1;
string res;
for (auto& x : v) {
if (!f) res += ' ';
f = 0;
res += to_string(x);
}
return res;
}
template <class A>
void write(A x) {
cout << to_string(x);
}
template <class H, class... T>
void write(const H& h, const T&... t) {
write(h);
write(t...);
}
void print() { write("\n"); }
template <class H, class... T>
void print(const H& h, const T&... t) {
write(h);
if (sizeof...(t)) write(' ');
print(t...);
}
void printGrid(vector<vector<int>> v) {
for (int i = 0; i < (int)v.size(); i++) {
for (int j = 0; j < (int)v[0].size(); j++) cout << v[i][j] << " ";
cout << "\n";
}
}
void SET(vector<int>& v, int c) {
for (int i = 0; i < (int)v.size(); i++) v[i] = c;
}
void SET(vector<vector<int>>& v, int c) {
for (int i = 0; i < (int)v.size(); i++)
for (int j = 0; j < (int)v[0].size(); j++) v[i][j] = c;
}
vector<long long> primes;
vector<long long> PL;
long long pw(long long a, long long b, long long m) {
a %= m;
long long r = 1;
while (b > 0) {
if (b & 1) r = (r * a) % m;
a = (a * a) % m;
b /= 2;
}
return r;
}
long long gcd(long long a, long long b) {
if (!b) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long fact(long long n, long long mod) {
long long ret = 1;
for (long long i = 1; i <= n; i++) ret = (ret * i) % mod;
return ret;
}
bool isPrime(long long n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (long long i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
void sieve(int M) {
PL.assign(M + 1, 0);
for (long long i = 2; i <= M; i++) {
if (PL[i]) continue;
PL[i] = i;
primes.push_back(i);
for (long long j = i * i; j <= M; j += i) PL[j] = i;
}
}
vector<long long> prime_factors(long long n) {
vector<long long> p;
for (long long i = 2; i * i <= n; i++) {
while (n % i == 0) {
p.push_back(i);
n /= i;
}
}
if (n > 1) {
p.push_back(n);
}
return p;
}
map<long long, long long> pf(long long n) {
map<long long, long long> p;
for (long long i = 2; i * i <= n; i++) {
while (n % i == 0) {
p[i]++;
n /= i;
}
}
if (n > 1) {
p[n]++;
}
return p;
}
vector<long long> prime_factors_small(long long n) {
vector<long long> p;
while (n > 1) {
long long now = PL[n];
while (n % now == 0) {
n /= now;
p.push_back(now);
}
}
return p;
}
map<long long, long long> pf_small(long long n) {
map<long long, long long> p;
while (n > 1) {
long long now = PL[n];
while (n % now == 0) {
n /= now;
p[now]++;
}
}
return p;
}
void solve() {
int n;
read(n);
if (n < 3) {
cout << -1;
} else {
for (int i = 0; i < n; i++) {
cout << n - i << " ";
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t = 1;
while (t--) {
solve();
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, n;
cin >> n;
if (n > 2) {
for (i = 2; i <= n; i++) {
cout << i << " ";
}
cout << 1 << endl;
} else
cout << -1 << endl;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;
import java.io.IOException;import java.io.PrintStream;import java.io.PrintWriter;
import java.security.AccessControlException;import java.util.Arrays;import java.util.Collection;
import java.util.Comparator;import java.util.List;import java.util.Map;import java.util.Objects;
import java.util.Scanner;import java.util.TreeMap;import java.util.function.Function;
import java.util.stream.Collectors;import java.util.stream.IntStream;import java.util.stream.LongStream;
import java.util.stream.Stream;public class _p000246A {static public void main(final String[] args)
throws IOException{p000246A._main(args);}
static private class p000246A extends Solver{public p000246A(){nameIn="in/900/p000246A.in";
singleTest=true;}@Override public void solve()throws IOException{int n=sc.nextInt();
if(sc.hasNextLine()){sc.nextLine();}pw.println(n>2?join(IntStream.rangeClosed(1,
n).map(i->n+1-i)):-1);}static public void _main(String[]args)throws IOException{new
p000246A().run();}}static private class Pair<K,V>{private K k;private V v;public
Pair(final K t,final V u){this.k=t;this.v=u;}public K getKey(){return k;}public
V getValue(){return v;}}static private abstract class Solver{protected String nameIn
=null;protected String nameOut=null;protected boolean singleTest=false;protected
boolean preprocessDebug=false;protected boolean doNotPreprocess=false;protected
PrintStream debugPrintStream=null;protected Scanner sc=null;protected PrintWriter
pw=null;final static String SPACE=" ";final static String SPACES="\\s+";private
void process()throws IOException{if(!singleTest){int t=lineToIntArray()[0];while(t--
>0){solve();}}else{solve();}}abstract protected void solve()throws IOException;protected
String[]lineToArray()throws IOException{return sc.nextLine().trim().split(SPACES);
}protected int[]lineToIntArray()throws IOException{return Arrays.stream(lineToArray()).mapToInt(Integer::valueOf).toArray();
}protected long[]lineToLongArray()throws IOException{return Arrays.stream(lineToArray()).mapToLong(Long::valueOf).toArray();
}protected void run()throws IOException{boolean done=false;try{if(nameIn!=null &&
new File(nameIn).exists()){try(FileInputStream fis=new FileInputStream(nameIn);PrintWriter
pw0=select_output();){done=true;sc=new Scanner(fis);pw=pw0;process();}}}catch(IOException
ex){}catch(AccessControlException ex){}if(!done){try(PrintWriter pw0=select_output();
){sc=new Scanner(System.in);pw=pw0;process();}}}private PrintWriter select_output()
throws FileNotFoundException{if(nameOut!=null){return new PrintWriter(nameOut);}
return new PrintWriter(System.out);}public static Map<Integer,List<Integer>>mapi(final
int[]a){return IntStream.range(0,a.length).collect(()->new TreeMap<Integer,List<Integer>>(),
(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));
}else{res.get(a[i]).add(i);}},Map::putAll);}public static Map<Long,List<Integer>>
mapi(final long[]a){return IntStream.range(0,a.length).collect(()->new TreeMap<Long,
List<Integer>>(),(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));
}else{res.get(a[i]).add(i);}},Map::putAll);}public static<T>Map<T,List<Integer>>
mapi(final T[]a){return IntStream.range(0,a.length).collect(()->new TreeMap<T,List<Integer>>(),
(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));
}else{res.get(a[i]).add(i);}},Map::putAll);}public static<T>Map<T,List<Integer>>
mapi(final T[]a,Comparator<T>cmp){return IntStream.range(0,a.length).collect(()->
new TreeMap<T,List<Integer>>(cmp),(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],
Stream.of(i).collect(Collectors.toList()));}else{res.get(a[i]).add(i);}},Map::putAll
);}public static Map<Integer,List<Integer>>mapi(final IntStream a){int[]i=new int[]{0};
return a.collect(()->new TreeMap<Integer,List<Integer>>(),(res,v)->{if(!res.containsKey(v))
{res.put(v,Stream.of(i[0]).collect(Collectors.toList()));}else{res.get(v).add(i[0]);
}i[0]++;},Map::putAll);}public static Map<Long,List<Integer>>mapi(final LongStream
a){int[]i=new int[]{0};return a.collect(()->new TreeMap<Long,List<Integer>>(),(res,
v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));
}else{res.get(v).add(i[0]);}i[0]++;},Map::putAll);}public static<T>Map<T,List<Integer>>
mapi(final Stream<T>a,Comparator<T>cmp){int[]i=new int[]{0};return a.collect(()->
new TreeMap<T,List<Integer>>(cmp),(res,v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));
}else{res.get(v).add(i[0]);}},Map::putAll);}public static<T>Map<T,List<Integer>>
mapi(final Stream<T>a){int[]i=new int[]{0};return a.collect(()->new TreeMap<T,List<Integer>>(),
(res,v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));
}else{res.get(v).add(i[0]);}},Map::putAll);}public static List<int[]>listi(final
int[]a){return IntStream.range(0,a.length).mapToObj(i->new int[]{a[i],i}).collect(Collectors.toList());
}public static List<long[]>listi(final long[]a){return IntStream.range(0,a.length).mapToObj(i
->new long[]{a[i],i}).collect(Collectors.toList());}public static<T>List<Pair<T,
Integer>>listi(final T[]a){return IntStream.range(0,a.length).mapToObj(i->new Pair<T,
Integer>(a[i],i)).collect(Collectors.toList());}public static List<int[]>listi(final
IntStream a){int[]i=new int[]{0};return a.mapToObj(v->new int[]{v,i[0]++}).collect(Collectors.toList());
}public static List<long[]>listi(final LongStream a){int[]i=new int[]{0};return
a.mapToObj(v->new long[]{v,i[0]++}).collect(Collectors.toList());}public static<T>
List<Pair<T,Integer>>listi(final Stream<T>a){int[]i=new int[]{0};return a.map(v->
new Pair<T,Integer>(v,i[0]++)).collect(Collectors.toList());}public static String
join(final int[]a){return Arrays.stream(a).mapToObj(Integer::toString).collect(Collectors.joining(SPACE));
}public static String join(final long[]a){return Arrays.stream(a).mapToObj(Long::toString).collect(Collectors.joining(SPACE));
}public static<T>String join(final T[]a){return Arrays.stream(a).map(v->Objects.toString(v)).collect(Collectors.joining(SPACE));
}public static<T>String join(final T[]a,final Function<T,String>toString){return
Arrays.stream(a).map(v->toString.apply(v)).collect(Collectors.joining(SPACE));}public
static<T>String join(final Collection<T>a){return a.stream().map(v->Objects.toString(v)).collect(Collectors.joining(SPACE));
}public static<T>String join(final Collection<T>a,final Function<T,String>toString)
{return a.stream().map(v->toString.apply(v)).collect(Collectors.joining(SPACE));
}public static<T>String join(final Stream<T>a){return a.map(v->Objects.toString(v)).collect(Collectors.joining(SPACE));
}public static<T>String join(final Stream<T>a,final Function<T,String>toString){
return a.map(v->toString.apply(v)).collect(Collectors.joining(SPACE));}public static
<T>String join(final IntStream a){return a.mapToObj(Integer::toString).collect(Collectors.joining(SPACE));
}public static<T>String join(final LongStream a){return a.mapToObj(Long::toString).collect(Collectors.joining(SPACE));
}public static List<Integer>list(final int[]a){return Arrays.stream(a).mapToObj(Integer::valueOf).collect(Collectors.toList());
}public static List<Integer>list(final IntStream a){return a.mapToObj(Integer::valueOf).collect(Collectors.toList());
}public static List<Long>list(final long[]a){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());
}public static List<Long>list(final LongStream a){return a.mapToObj(Long::valueOf).collect(Collectors.toList());
}public static<T>List<T>list(final Stream<T>a){return a.collect(Collectors.toList());
}public static<T>List<T>list(final T[]a){return Arrays.stream(a).collect(Collectors.toList());
}}}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
n = int(n)
if n <= 2:
print(-1)
elif n <= 50:
result = [i for i in range(n, 0, -1)]
for el in result:
print(el, 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 sys, math
def rs():
return sys.stdin.readline().strip()
def ri():
return int(sys.stdin.readline().strip())
def ras():
return sys.stdin.readline().strip().split()
def rai():
return map(int,sys.stdin.readline().strip().split())
def main():
n = ri()
if n <= 2:
return -1
else:
arr = [3,3] + [1 for i in range(2, n)]
return ' '.join(map(str, arr))
if __name__ == "__main__":
print main() | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
N = int(sys.stdin.read())
if N < 3:
print - 1
else:
print " ".join([str(i) for i in range(N, 0, -1)])
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) != EOF) {
if (n == 1 || n == 2)
printf("-1\n");
else {
printf("%d", n);
for (int i = n - 1; i >= 1; i--) printf(" %d", i);
printf("\n");
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int main() {
int n;
scanf("%d", &n);
if (n == 1 || n == 2)
puts("-1");
else {
printf("100 99 98 ");
for (int i = 1; i <= n - 3; i++) printf("%d ", i);
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
int n, i;
cin >> n;
if ((n == 1) || (n == 2)) {
cout << -1;
} else {
for (i = n; i >= 1; i--) {
cout << i << ' ';
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n;
std::cin >> n;
switch (n) {
case 1:
case 2:
std::cout << "-1\n";
break;
default:
for (int i = n; i >= 1; --i) {
std::cout << i << ((i == 1) ? '\n' : ' ');
}
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author o_panda_o([email protected])
*/
public class Code_246A_BuggySorting{
public static void main(String[] args){
InputStream inputStream=System.in;
OutputStream outputStream=System.out;
InputReader in=new InputReader(inputStream);
OutputWriter out=new OutputWriter(outputStream);
_246A_ solver=new _246A_();
solver.solve(1,in,out);
out.close();
}
static class _246A_{
public void solve(int testNumber,InputReader in,OutputWriter out){
int n=in.nextInt();
if(n<=2){
out.print(-1);
return;
}
for(int i=n;i>=1;--i) out.print(i,"");
}
}
static class InputReader{
private InputStream stream;
private byte[] buf=new byte[1024];
private int curChar;
private int numChars;
private InputReader.SpaceCharFilter filter;
public InputReader(InputStream stream){
this.stream=stream;
}
public int read(){
if(numChars==-1){
throw new InputMismatchException();
}
if(curChar>=numChars){
curChar=0;
try{
numChars=stream.read(buf);
}catch(IOException e){
throw new InputMismatchException();
}
if(numChars<=0){
return -1;
}
}
return buf[curChar++];
}
public int nextInt(){
int c=read();
while(isSpaceChar(c)){
c=read();
}
int sgn=1;
if(c=='-'){
sgn=-1;
c=read();
}
int res=0;
do{
if(c<'0' || c>'9'){
throw new InputMismatchException();
}
res*=10;
res+=c-'0';
c=read();
}while(!isSpaceChar(c));
return res*sgn;
}
public boolean isSpaceChar(int c){
if(filter!=null){
return filter.isSpaceChar(c);
}
return isWhitespace(c);
}
public static boolean isWhitespace(int c){
return c==' ' || c=='\n' || c=='\r' || c=='\t' || c==-1;
}
public interface SpaceCharFilter{
public boolean isSpaceChar(int ch);
}
}
static class OutputWriter{
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream){
writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer){
this.writer=new PrintWriter(writer);
}
public void print(Object... objects){
for(int i=0;i<objects.length;i++){
if(i!=0){
writer.print(' ');
}
writer.print(objects[i]);
}
}
public void close(){
writer.close();
}
public void print(int i){
writer.print(i);
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;
/**
* Jan 11, 2013
*/
/**
* @author DOAN Minh Quy
* @email [email protected]
*/
public class A246 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new A246().run();
}
void run(){
Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
PrintStream printer = new PrintStream(System.out);
int count = scanner.nextInt();
if ( count < 3 ){
printer.print(-1);
}else{
while(count>0){
printer.print((count--)+" ");
}
}
scanner.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 | # It's all about what U BELIEVE
import sys
input = sys.stdin.readline
def gint(): return int(input())
def gint_arr(): return list(map(int, input().split()))
def gfloat(): return float(input())
def gfloat_arr(): return list(map(float, input().split()))
def pair_int(): return map(int, input().split())
###############################################################################
INF = (1 << 31)
MOD = "1000000007"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0, -1]
############################ SOLUTION IS COMING ###############################
n = gint()
if n <= 2:
print(-1)
else:
for i in range(n):
print(n - i, end=" ")
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by IntelliJ IDEA.
* User: prasoon.m
* Date: 11/21/12
* Time: 9:09 PM
* To change this template use File | Settings | File Templates.
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
int n = Integer.parseInt(line);
if( n < 3 ) {
System.out.println("-1");
return;
}
String answer = "";
for( int i= n ; i> 0 ; i-- )
answer += i + " ";
answer = answer.trim();
System.out.println(answer);
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(System.in);
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = s.nextInt();
if(n < 3) {
System.out.println(-1);
} else {
for(int i = 0; i < n; i++) {
if(i != n-1) out.print((n-i) + " ");
else out.println(n-i);
}
out.flush();
}
out.close();
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
final int n = s.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 | n = int(input())
if n==1 or n==2:
print(-1)
else:
for i in range(2, n+1):
print(i, end = ' ')
print(1) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[55];
int main() {
int n, i = 0, flag = 1;
cin >> n;
if (n == 1 || n == 2) {
cout << "-1";
return 0;
}
i = 0;
int k = n;
while (i < n) {
cout << k << " ";
i++;
k--;
}
}
| 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 CodeforcesBadSort{
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.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 | n=int(input())
if n==1 or n==2:
print(-1)
else:
arr=[int(i) for i in range(n,0,-1)]
print(*arr) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print('-1')
else:
l = ['2']
l += ['3']*(n-2)
l += ['1']
print(' '.join(l)) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n < 3)
System.out.println(-1);
else {
for (int i = 2; i <= n; i++) {
System.out.print(i + " ");
}
System.out.print(1);
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
if (n == 1 || n == 2)
cout << -1;
else
for (int i = n; i > 0; i--) cout << i << " ";
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(raw_input())
if (n == 1) or (n == 2):
print "-1"
else:
res = "99 100 "
for i in xrange(0, n - 2):
res += "1 "
print 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 | #include <bits/stdc++.h>
int main() {
int n, i;
scanf("%d", &n);
if (n <= 2)
printf("-1");
else
for (; n > 0; n--) printf("%d ", n);
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void precompute(void) {}
int main() {
int n, i;
precompute();
while (scanf("%d", &n) != EOF) {
if (n <= 2)
printf("-1\n");
else {
for (i = 0; i < n; i++) {
printf("%d ", 100 - 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()
a = range(n, 0, -1)
if n > 2:
print ' '.join(map(str, a))
else:
print -1
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
import java.util.Vector;
import java.util.Arrays;
import java.math.BigInteger;
public class Main {
// This is my functions
static double u(double x1,double y1,double x2,double y2){
return Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
}
static int[] a = new int[10000000];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n,a,b,c,ans=0;
n=scan.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.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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();
}
}
class TaskA {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
if(n <= 2) out.println(-1);
else {
for(int i = n;i >=1 ;i--) {
out.print(i+ " ");
}
out.println();
}
}
}
class InputReader {
private BufferedReader br;
private StringTokenizer st;
public InputReader(InputStream in) {
br=new BufferedReader(new InputStreamReader(in));
try {
st=new StringTokenizer(br.readLine());
} catch (IOException ignored) {
}
}
public int nextInt(){
return Integer.parseInt(st.nextToken());
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=input()-2
print[-1,'2 3'+' 1'*n][n>0] | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if n==1 or n==2:
print(-1)
else:
for i in range(n+1,1,-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.*;
public class CF151A{
public static void main(String args[]) throws IOException {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String line = stdin.readLine();
int n = Integer.parseInt(line);
if(n<3) {
System.out.println(-1);
}else{
System.out.print("2 3 1");
for(int i=3; i<n; i++){
System.out.print(" "+(i+1));
}
System.out.println();
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
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.*;
public class CF0246A
{
public static void main(String[] helloWorld) throws IOException
{
BufferedReader sIn = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(sIn.readLine());
StringBuilder sB = new StringBuilder();
if (n < 3)
sB.append("-1");
else
{
for (int i = 1; i < n; i ++)
sB.append("2 ");
sB.append("1");
}
System.out.println(sB);
}
}
| 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;
return 0;
}
for (int i = n; i >= 1; i--) {
cout << i;
if (i != 1)
cout << " ";
else
cout << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
if (n < 3) {
cout << "-1";
return 0;
}
cout << n << " " << n - 1 << " ";
for (int i = 1; i < n - 1; i++) cout << i << " ";
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import sys
n = int(sys.stdin.readline())
if n < 3:
print -1
else:
for i in xrange(2, n + 1):
print i,
print 1
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | __author__ = 'sunhaowen'
n = int(raw_input())
if n == 1 :
print(-1)
elif n == 2:
print(-1)
else :
ans = ""
for i in xrange(n) :
ans += str(n - i) + " "
print(ans)
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
x = [4, 3, 2]
y = [1] * (n - 3)
print(*(x + y))
| 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 == 1 or n == 2:
print(-1)
else:
print("8","18","7",end=" ")
for i in range(n-3):
print(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 | #include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
const int MAXN = 1e2;
int main() {
ios::sync_with_stdio(0);
int n;
scanf("%d", &n);
if (n <= 2) {
printf("-1");
return 0;
}
for (n; n; --n) printf("%d ", n);
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.RandomAccess;
import java.util.AbstractList;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Jacob Jiang
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
TaskA solver = new TaskA();
solver.solve(1, in, out);
out.close();
}
}
class TaskA {
public void solve(int testNumber, InputReader in, OutputWriter out) {
int n = in.nextInt();
if (n <= 2) {
out.println(-1);
} else {
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = n - i;
}
out.printLine(ArrayUtils.asList(a).toArray());
}
}
}
class InputReader {
private InputStream stream;
private byte[] buf = new byte[1 << 16];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c & 15;
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public static boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
}
class OutputWriter {
private PrintWriter writer;
public OutputWriter(OutputStream stream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void println(int x) {
writer.println(x);
}
public void print(Object obj) {
writer.print(obj);
}
public void println() {
writer.println();
}
public void print(char c) {
writer.print(c);
}
public void close() {
writer.close();
}
public void printItems(Object... items) {
for (int i = 0; i < items.length; i++) {
if (i != 0) {
print(' ');
}
print(items[i]);
}
}
public void printLine(Object... items) {
printItems(items);
println();
}
}
class ArrayUtils {
public static List<Integer> asList(int[] array) {
return new IntList(array);
}
private static class IntList extends AbstractList<Integer> implements RandomAccess {
int[] array;
private IntList(int[] array) {
this.array = array;
}
public Integer get(int index) {
return array[index];
}
public Integer set(int index, Integer element) {
int result = array[index];
array[index] = element;
return result;
}
public int size() {
return array.length;
}
}
}
| 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 {
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 | n = input()
if n==1:
print -1
elif n==2:
print -1
else:
print 3,2,1,
for i in range(4,n+1):
print i,
print ""
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INFTY = 1 << 29;
const double EPS = 1e-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& a) {
os << '[';
for (int i = int(0); i < int(a.size()); i++) os << (i ? " " : "") << a[i];
return os << ']';
}
int main() {
for (int n; cin >> n && n;) {
if (n <= 2) {
cout << -1 << endl;
continue;
}
for (int i = int(0); i < int(n); i++)
cout << n - i << (i < n - 1 ? ' ' : '\n');
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = int(input())
if n<=2:
print(-1)
else:
for i in range(n):
print(n-i,end = " ") | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
if (x <= 2)
cout << "-1" << endl;
else {
for (int i = x; i >= 1; i--) cout << i << " ";
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
a = []
for i in range(n):
a.append(n-i)
if n > 2:
print ' '.join([str(d) for d in a])
else:
print -1 | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 |
import java.util.Scanner;
public class A151 {
public void solve() {
Scanner sc = new Scanner(System.in);
int i = 0, j = 0, k = 0;
int n = sc.nextInt();
if (n == 1 || n==2) {
System.out.println("-1");
System.exit(0);
}
for (j = n; j > 0; --j) {
System.out.print(j + " ");
}
}
public static void main(String[] args) {
new A151().solve();
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(raw_input())
if n==1 or n==2:
print -1
else:
x=list(xrange(1,n+1))
x.reverse()
for i in x:
print i, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.io.*;
public class Main {
/**
* @author hunglee
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StreamTokenizer in = new StreamTokenizer(br);
PrintWriter out = new PrintWriter(System.out);
in.nextToken();
int n = (int) in.nval;
if (n <= 2) {
out.println(-1);
} else {
out.print("3 2");
for (int i = 2; i < n; ++i)
out.print(" 1");
out.println();
}
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 | import java.io.*;
import java.util.*;
public class Main
{
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 solve(int n){
if(n<=2){
System.out.println(-1);
return;
}
for(int i=n;i>=1;i--)
System.out.print(i+" ");
System.out.println();
}
public static void main(String[] args) {
FastReader sc=new FastReader();
int n=sc.nextInt();
solve(n);
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
//Sandro Mirianashvili
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
if(N < 3){
System.out.print(-1);
System.exit(0);
}
for(int i = N ; i > 0 ; i --)
System.out.print(i + " ");
sc.close();
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | from random import *
n = input()
if n<=2:
print -1
exit(0)
a = [100,100]
for i in xrange(n-2):
a.append(1)
for i in a:
print i,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
if n > 2:
for i in range(n):
print n-i,
else:
print -1
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n=int(input())
if(n>2):
for i in range(2,n+1):
print(i)
print(1)
else:
print(-1) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, n;
int main() {
cin >> n;
if (n <= 2) {
cout << -1;
return 0;
}
for (i = n; i > 0; i--) {
cout << i << " ";
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
int i, j, n;
int A[105];
while (scanf("%d", &n) != EOF) {
if (n == 1 || n == 2)
printf("-1\n");
else {
printf("%d", n);
for (i = n - 1; i >= 1; i--) printf(" %d", i);
printf("\n");
}
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | n = input()
a = [n-i for i in range(n)]
sorted = [i for i in range(1, n+1)]
for i in range(n-1):
for j in range(i,n-1):
if(a[j] > a[j+1]):
a[j], a[j+1] = a[j+1], a[j]
if a == sorted:
print -1
else:
print ' '.join([str(n-i) for i in range(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 |
t=int(input())
if t>2:
for i in range(t):
print(t-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 | #include <bits/stdc++.h>
using namespace std;
long long int n;
int main() {
cin >> n;
if (n == 1 || n == 2) cout << "-1";
for (int i = n; i >= 1; i--) {
if (n != 2 && n != 1) 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 sys
n = int(raw_input())
if n <= 2:
print -1
else:
a = []
while n > 0:
a.append(n)
n -= 1
sys.stdout.write(" ".join(str(x) for x in a)) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.
loop integer variable i from 1 to n - 1
loop integer variable j from i to n - 1
if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
Input
1
Output
-1 | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<long long int> v, v1, v2, v3;
string s1, s2, s3;
int main() {
long long int a[100001] = {0}, b[100001], c = 0, d = 0, i, j, k = 0, l = 0, m,
n, p = 0, q, t, ct = 0, ct1 = 0, ct2 = 0, ck = 0, ck1 = 0,
ck2 = 0, ln, ln1, start, end, mid;
long long int a1 = 0, a2 = 0, a3 = 0, a4 = 0, sum = 0, sum1 = 0, max1, max2,
min1, min2;
double x, y, z;
char s[1101], st[1001], ch, ch1, ch2;
cin >> n;
if (n < 3)
cout << "-1";
else {
for (i = n; i > 0; i--) cout << i << " ";
}
return 0;
}
| CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.