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 ... | 2 | 7 | n=int(input())
if n<=2:
print(-1)
else:
print(*[n-x for x in range(n)]) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
public class BuggySorting {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
if(n==1||n==2)
System.out.println(-1);
else
for(int i=n;i>0;i--)
System.out.print(i+" ");
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if ( n<=2 ) {
System.out.println(-1);
} else {
for ( int i = n ; i>=1 ; --i ) {
System.out.print(i+" ");
}
System.out.println();
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.Scanner;
public class AUnsuccessfulSorting {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int inputByte=sc.nextInt();
if(inputByte<3) {
System.out.print(-1);
}
else {
for(int i=inputByte; i>0; ... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
inline int ADD(int a, int b) {
a += b;
if (a >= 1000000007) a -= 1000000007;
return (int)a;
}
inline void ADDTO(int &a, int b) {
a += b;
if (a >= 1000000007) a -= 1000000007;
}
inline void SUBTO(int &a, int b) {
a -= b;
if (a < 0) a += 1000000007;
}
inline int... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n < 3) {
cout << -1 << endl;
return 0;
}
cout << 5 << " " << 6 << " " << 4 << " ";
for (i = 1; i <= n - 3; i++) cout << 5 << " ";
cout << endl;
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 |
import java.io.*;
import java.util.*;
public class cikk
{
static class InputReader {
private InputStream stream;
private byte[] inbuf = new byte[1024];
private int start= 0;
private int end = 0;
public InputReader(InputStream stream) {
this.stream = stream;
... | 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 ... | 2 | 7 | n = int(input())
if n < 3:
print(-1)
else:
print(' '.join(str(i) for i in range(n, 0, -1)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 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 ... | 2 | 7 | n=int(input())
if n<3:
print(-1)
else:
a=[i+1 for i in range(n)]
a=sorted(a,reverse=True)
for b in a:
print b, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class CF246taskA {
StringTokenizer st;
BufferedReader in;
PrintWriter out;
public static void main(String[] args) throws NumberFormatExcept... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long int n;
cin >> n;
if (n < 3) {
cout << -1;
return 0;
}
long long int a[n];
a[0] = n;
a[1] = n;
for (long long int I = 2; I < n; I += 1) a[I] = I;
for (long long int I = 0; I < n; I += 1) cout << ... | 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 ... | 2 | 7 | import sys
import math
#import random
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
return(int(input()))
def inara():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
d... | 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 ... | 2 | 7 | import sys
n = int(sys.stdin.readline().strip())
if n < 3:
print(-1)
else:
print(' '.join([str(n-i) for i in range(0, n)]))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n < 3)
cout << "-1\n";
else {
for (i = n; i > 1; i--) cout << i << " ";
cout << "1" << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | def main():
n = int(raw_input())
if n < 3:
print -1
return
print ' '.join(map(str, list(reversed(xrange(1, n + 1)))))
if __name__ == '__main__':
main()
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n=int(input())
print(-1 if n<=2 else "2 3 "+"1 "*(n-2))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n > 2:
print " ".join(map(str, reversed(range(1, n + 1))))
else:
print "-1"
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
... | 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 ... | 2 | 7 |
import java.util.Scanner;
public class buggysorting {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
if (n<3)
{
System.out.print(-1);
}
else
{
for (int i=n; i>0; i--)
{
System.out.print(i);
System.out.print(" ");
}
}
}
} | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3)
cout << -1 << endl;
else {
for (int i = n; i >= 2; i--) cout << i << " ";
cout << 1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.Scanner;
public class Solver {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if(n<=2){
System.out.print("-1");
}else{
for(int i = n; i>0; i--){
System.out.print(i+" ");
}
}
}... | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n < 3:
print(-1)
else:
while n > 0:
print(n, end=" ")
n -= 1 | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
ios_base::sync_with_stdio(false);
cin >> n;
if (n < 3) {
cout << "-1";
return 0;
}
for (int i = n; i >= 1; i--) cout << i << ' ';
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | from sys import stdin
n=int(stdin.readline())
if n==1 or n==2:
print("-1")
else:
print("2 3 1",end=" ")
for i in range(4,n+1):
print(i,end=" ")
print() | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
if n < 3:
print -1
exit()
for i in xrange(1, n + 1):
if i == 1:
print 2,
elif i == 2:
print 3,
elif i == 3:
print 1,
else:
print i, | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2)
cout << -1;
else {
for (int i = 2; i <= n; i++) cout << i << " ";
cout << 1;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
if n==1 or n==2:
print "-1"
else:
while n>0:
print n,
n-=1 | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
if n <= 2:
print -1
else:
for i in range(n) :
print n - i,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
unsigned long long n = 0, m = 100, i, j, k, ans = -1, y, x, z, l, a, b, c, s,
o = 0;
bool can = false;
int main() {
std::ios_base::sync_with_stdio(false);
cin >> n;
if (n < 3)
cout << -1;
else
while (n--) cout << n + 1 << " ";
return 0;
... | CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) {
cout << "-1\n";
return 0;
}
cout << "2 3";
for (int i = 1; i <= n - 2; ++i) {
cout << " 1";
}
cout << '\n';
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | def stripped_line():
return raw_input().strip()
def read_ints():
return map(int, stripped_line().split())
n = read_ints()[0]
if n <= 2:
print -1
else:
res = range(1, n + 1)
res.reverse()
print " ".join([str(x) for x in res])
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | X = int(input())
print("".join([str(i) + " " for i in range(X, 0, -1)]) if X > 2 else -1)
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(raw_input())
if (n <= 2):
print("-1")
else:
for i in range(2, n + 1):
print(str(i) + " ")
print("1\n") | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print(-1)
else:
for i in range(n, 0, -1):
print(i, end=" ") | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, ret;
while (cin >> n) {
if (n == 1 || n == 2)
cout << -1 << endl;
else {
int cnt = 0;
for (int i = n; i >= 1; i--) {
if (cnt) cout << " ";
cnt++;
cout << i;
}
cout << endl;
}
}
ret... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
if (n < 3)
cout << -1 << "\n";
else {
for (int i = n; i > 0; i--)
if (i == 1)
cout << i << "\n";
else
cout << i << " ";
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
if n < 3:
print -1
exit()
else:
print ' '.join(map(str, xrange(n, 0, -1)))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
print(' '.join(str(2 - x // (n - 1)) for x in range(n)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if(n <= 2):
print(-1)
else:
arr = list(range(1, n + 1))
arr.reverse()
arr = [str(i) for i in arr]
print(" ".join(arr))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n, i;
scanf("%d", &n);
if (n == 1 || n == 2)
printf("-1\n");
else {
printf("3 2");
for (i = 3; i <= n; i++) printf(" 1");
printf("\n");
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()-2;
if n<1:
print -1
else:
print '2 3','1 '*n
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ar {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
... | 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 ... | 2 | 7 | def bad_sort ():
n = int ( raw_input () )
if not (1 <= n <= 50): return -1
if (n < 3): print -1
else: print " ".join( map ( str, range (n,0,-1)) )
bad_sort () | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void makra() {
int n;
cin >> n;
if (n <= 2)
cout << "-1\n";
else {
for (int i = 0; i < n; ++i) cout << n - i << " ";
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tc = 1;
while (tc--) {
makra();
... | 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 ... | 2 | 7 | n = int(input())
a = [n-i for i in range(n)]
def so(n, a):
for i in range(n-1):
for j in range(i, n-1):
a[j], a[j+1] = a[j+1], a[j]
if n in (1, 2):
print(-1)
else:
print(' '.join(map(str, a)))
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
import java.io.*;
public class A {
FastScanner in;
PrintWriter out;
public void solve() throws IOException {
int n = in.nextInt();
if (n <= 2) {
out.println(-1);
return;
}
for (int i = 0; i < n -1 ; i++) {
out.print(99... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long n, i, mas[100], j, t;
cin >> n;
for (i = 0; i < n; ++i) mas[i] = n - i;
for (i = 0; i < n - 1; ++i)
for (j = i; j < n - 1; ++j)
if (mas[j] > mas[j + 1]) {
t = mas[j];
mas[j] = mas[j + 1];
mas[j + 1] = t;
}
... | 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 ... | 2 | 7 | #coding:utf-8
import sys
n = int(sys.stdin.readline())
if n > 2:
for a in range(n, 0, -1):
print a,
print
else:
print '-1'
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.Scanner;
public class Prob246A {
public static void main(String[] Args) {
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
if (x <= 2)
System.out.println(-1);
else {
for (int i = 1; i < x; i++)
System.out.print((i + 1) + " ");
System.out.println(1);
}
}
}
| JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve(istream &in, ostream &out) {
int n;
in >> n;
if (n < 3) {
out << -1;
return;
}
for (int i = 0; i < n; ++i) out << n - i << " ";
}
int main() {
solve(cin, cout);
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n=int(raw_input())
if n==1 or n==2: print -1
else:
for i in xrange(n):
print n-i,
print
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n=int(input())
if n<=2:
print('-1')
else:
s=''
for i in range(n,0,-1):
s+=str(i)+' '
print(s) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import sys
n=int(sys.stdin.readline())
a=[x for x in range(1,n+1)]
a.sort(reverse=True)
b=[str(x) for x in a]
if n<=2:
print -1
else:
print ' '.join(b) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
}
template <class T>
inline... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1 || n == 2)
cout << -1 << endl;
else {
while (true) {
cout << n;
if (n != 1) cout << ' ';
n--;
if (n == 0) return 0;
}
}
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.text.*;
public class Main {
static long mod = 1000_000_007;
static long mod1 = 998244353;
static boolean fileIO = false;
static boolean memory = true;
static FastScanner f;
static PrintWriter pw;
static double eps... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (~scanf("%d", &n)) {
if (n <= 2)
printf("-1\n");
else {
int flag = 2;
for (int i = n; i != 1; i--) {
while (flag) {
printf("%d ", i);
flag--;
if (flag == 0) i--;
}
... | 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 ... | 2 | 7 | import math
def solve(n):
if n <= 2:
return [-1]
return [i for i in range(n,0,-1)]
def main() :
n = int(input())
# arr = list(map(int, input().split(' ')))
# arr = []
# for _ in range(3):
# arr.append(input())
print(*solve(n))
main()
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
import java.io.*;
public class Buggy_Sorting
{
public static void main(String args[]) throws Exception
{
BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
int size=Integer.parseInt(f.readLine());
if(size<=2)
System.out.println(-1);
else
{
for(int x=size;x>=1;x-... | 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 ... | 2 | 7 | import sys
#my_file = sys.stdin
#my_file = open("input.txt", "r")
n = int(input())
if n > 2:
lst = list(range(n-1,0,-1))
lst.insert(0, n-1)
for i in lst:
print(i, end=" ")
else:
print(-1) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if (n <= 2):
print(-1)
else:
for i in range(n - 1, -1, -1):
print(i + 1, end = ' ') | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner Sc=new Scanner(System.in);
... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
if (a > 2) {
for (int i = a; i > 0; i--) cout << i << " ";
} else
cout << "-1";
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #July 4, 2014
sa=int(input())
string=''
if sa==1 or sa==2:
print("-1")
else:
for x in range(sa, 0, -1):
string+=str(x)
string+=' '
print(string.strip())
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
if ( n <= 2 ) : print -1
else : print n-1,n,' '.join(map(str,range(1,n-1))) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n <= 2:
print(-1)
else:
print(*[x for x in range(n, 0, -1)])
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import sys
def RedirectIO():
sys.stdin=open("test.in","r")
# sys.stdout=open("output.txt","w")
#RedirectIO()
def main():
n=int(raw_input())
if n<3:
print -1
else:
for i in xrange(n,0,-1):
print i,
main()
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
if (n <= 2)
cout << -1;
else
while (n--) cout << n + 1 << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n=int(raw_input())
if n<3:
print -1
else:
print " ".join(map(str,range(2,n+1)+[1])) | PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | 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 ... | 2 | 7 |
import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class codeforce {
static Scanner sc = new Scanner(System.in);
//static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintStream out = new PrintStream(System.out);
//public static int mod... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T Abs(T x) {
return x > 0 ? x : -x;
}
template <class T>
T Max(T a, T b) {
return a > b ? a : b;
}
template <class T>
T Min(T a, T b) {
return a < b ? a : b;
}
template <class T>
T gcd(T a, T b) {
return a % b == 0 ? b : gcd(b, a % b);
}
bool isVo... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n;
int a[N];
int main() {
cin >> n;
if (n < 3) {
cout << -1;
return 0;
}
for (int i = 0; i < n; i++) a[i] = n - i;
for (int i = 0; i < n; i++) cout << a[i] << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.*;
import java.util.*;
public class p222
{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter wf = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br... | 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 ... | 2 | 7 | n = int(input())
if n < 3:
print(-1)
else:
print(2, 2, *([1] * (n - 2))) | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Steve Phillips / elimisteve
# 2012.11.21
n = int(raw_input())
#array = [2, 1, 3, 9, 8, 7, 7, 8, 3, 2, 3]
if n <= 2:
print -1
else:
print 2, 3,
for _ in xrange(n-2):
print 1,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 |
import java.util.*;
import java.math.*;
public class main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
if(n<=2){System.out.println("-1");return ;}
int [] array = new int[n+1];
for(int i=1 ; i<... | 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 ... | 2 | 7 |
n = int(input())
if n <= 2:
print(-1)
else:
while n > 0:
print(n, end=' ')
n -= 1
# CodeForcesian
# ♥
# اگه ایمان داری که روزای خوب تو راهن
# روزای خوب قطعا به سمتت میاد
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = input()
print(-1 if n < 3 else ' '.join(map(str, range(n, 0, -1))))
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, n;
int main() {
cin >> n;
if (n == 1 || n == 2) {
cout << "-1\n";
return 0;
}
cout << "2\n";
for (i = n; i >= 1; --i) {
if (i != 2) cout << i << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(input())
if n == 1 or n == 2:
print(-1)
else:
for i in range(n, 0, -1):
print(i, end = ' ') | PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.*;
public class BuggySorting {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n == 1||n==2) {
System.out.println(-1);
} else {
for (int i = 0; i < n; i++) {
System.out.... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) {
cout << "-1";
return 0;
}
for (int i = n; i >= 1; i--) cout << i << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.util.Scanner;
public class prog {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int asd=scan.nextInt();
if(asd<=2){
System.out.println(-1);
}
else{
System.out.print(4+" ");
System.out.print(5+"... | 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 ... | 2 | 7 | n = int(input())
if n < 3 :
print(-1)
exit()
for i in range(n, 0, -1):
print(i, end = ' ')
| PYTHON3 |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.*;
import java.util.*;
public class p246a
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n<3) System.out.println("-1");
else
{
for(int i=n;i>0;i--) System.out.print(i+" ");
}
}
... | JAVA |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
if (n == 1 || n == 2)
cout << -1;
else
cout << 5 << " " << 4 << " " << 2 << " ";
for (i = 0; i < n - 3; i++) cout << 1 << " ";
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int i, n;
scanf("%d", &n);
if (n <= 2)
printf("-1\n");
else
for (i = n; i >= 1; i--) printf("%d ", i);
return (0);
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 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 ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Solution {
public static final int MOD = 1000050131;
public static void main(String args[]) throws IOException {
// BufferedReader br = new BufferedReader(new FileReader("c://tmp//in... | 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 ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 3)
cout << "-1";
else
while (n > 0) cout << n-- << " ";
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n > 2) {
for (int i = 2; i <= n; i++) {
cout << i << " ";
}
cout << 1 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 2) return cout << -1, 0;
for (int i = 0; i < n - 1; i++) cout << 2 << " ";
cout << 1;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1 || n == 2)
cout << -1 << endl;
else {
cout << n;
for (int i = n - 1; i >= 1; i--) cout << " " << i;
}
return 0;
}
| CPP |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
fast();
int n;
cin >> n;
if (n > 2) {
for (int i = 2; i <= n; ++i) {
cout << i << " ";
}
cout << 1 << endl;
} else {
cout << -1 << endl;
}
... | 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 ... | 2 | 7 | n=int(raw_input())
if(n<=2):
print -1
else:
print 99,100,98,
for i in range(n-3):
print i+1,
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int n = in.nextInt();
if (n > 2) {
for (int i=0;i<n;i++)... | 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 ... | 2 | 7 | #!/usr/bin/python
n = input()
print ' '.join([`n-i` for i in xrange(n)]) if n > 2 else -1
| PYTHON |
246_A. Buggy Sorting | Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ... | 2 | 7 | n = int(raw_input())
if n < 3:
print "-1"
else:
for x in reversed(xrange(n)):
print x + 1, | PYTHON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.