| Task: | Järjestys |
| Sender: | planckcons |
| Submission time: | 2016-10-05 19:48:45 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.14 s | 1 | details |
| #2 | RUNTIME ERROR | 0.18 s | 2 | details |
| #3 | RUNTIME ERROR | 0.55 s | 3 | details |
Code
import java.util.Scanner;
import static java.lang.System.arraycopy;
import java.util.Arrays;
import java.util.Collections;
public class Jarjestys {
static int[] arr /*= {4, 5, 2, 7, 8, 1, 9, 6, 3}*/;
static int n;
public static void main(String[] args) {
// n = arr.length;
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] arr = new int[n];
for(int i : arr)
{
arr[i] = scan.nextInt();
}
String fin = "";
for(int i = n; i > 0; i--)
{
fin += finder(i) + " ";
}
System.out.println(n);
System.out.println(fin);
}
public static int[] swap(int n2, int[] arr, int p)
{
int a = n2-(p+1);
int[] arr2 = new int[n2];
int[] arr3 = new int[a];
arraycopy(arr, 0, arr2, a, p+1);
arraycopy(arr, p+1, arr3, 0, a);
Collections.reverse(Arrays.asList(arr3));
arraycopy(arr3, 0, arr2, 0, a);
return arr2;
}
static int finder(int i)
{
for(int j = 0; j < i; j++)
{
if(arr[j] == i)
{
arr = swap(i ,arr, j);
return j+1;
}
}
return 0;
}
}
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 10 9 3 4 7 6 5 10 2 8 1 |
| correct output |
|---|
| 32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NullPointerException at Jarjestys.finder(Jarjestys.java:50) at Jarjestys.main(Jarjestys.java:28)
Test 2
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 650 716 982 41 133 1000 876 92... |
| correct output |
|---|
| 3984 207 207 206 207 128 127 126 12... |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NullPointerException at Jarjestys.finder(Jarjestys.java:50) at Jarjestys.main(Jarjestys.java:28)
Test 3
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 94703 47808 62366 31885 7091 8... |
| correct output |
|---|
| 399956 98676 98676 98675 98676 62994 ... |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NullPointerException at Jarjestys.finder(Jarjestys.java:50) at Jarjestys.main(Jarjestys.java:28)
