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
//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{ ...
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
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 ...
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 ...
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 ...
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 ...
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 ...
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();...
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 = 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 ...
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 ...
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 ...
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 = ...
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 == 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 ...
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 ...
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 { retur...
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 = 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 ...
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 ...
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(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 ...
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...
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; 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 ...
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 ...
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 ...
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 ...
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++) {...
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 = 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 ...
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(...
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.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 ...
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; 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 ...
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); } e...
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: 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
#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 ...
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 ...
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....
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 = 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 ...
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 ...
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 ...
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 ...
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....
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 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 = sto...
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 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 ...
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;im...
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 = 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 ...
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: ...
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 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 ...
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 ...
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 ...
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 ...
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 ...
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.Input...
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.BufferedReader; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Scanner; /** * Jan 11, 2013 */ /** * @author DOAN Minh Quy * @email mquy.doan@gmail.com */ public class A246 { /** * @param args */ public static void main(String[] args) { // ...
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
# 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()) ###################...
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; /** * 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) thr...
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.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) ...
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 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 ...
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 ...
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 ...
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 { ...
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==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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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]...
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.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 ...
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=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 ...
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 ...
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{ ...
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: 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.*; 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 { ...
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; 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of 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 { 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
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 ...
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...
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: 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 ...
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 ...
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 ...
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;...
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(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 ...
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.nextTok...
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.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String nex...
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 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 --) ...
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
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 ...
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 ...
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 ...
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 ...
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--) print...
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() 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 ...
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 ...
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 ...
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 ...
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...
CPP