Task: | Järjestys |
Sender: | planckcons |
Submission time: | 2016-10-06 12:51:54 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.13 s | 1 | details |
#2 | WRONG ANSWER | 1.20 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.Scanner;import static java.lang.System.arraycopy;import java.util.Arrays;import java.util.Collections;public class Jarjestys2 {static int[] arr;static int n;static int c;public static void main(String[] args) {Scanner scan = new Scanner(System.in);n = scan.nextInt();int uno = 0;arr = new int[n];// n = arr.length;for(int i = 0; i < n; i++){arr[i] = scan.nextInt();if(arr[i] == 1)uno = i + 1;}String fin = uno + " ";reverse(arr, 0, uno);for(int i = 0; i < arr.length; i++)System.out.print(arr[i]);System.out.println();for(int i = 2; i < n; i++){fin += turner(i);}fin += (n-1);System.out.println((c+2) + " " + fin);}public static String turner(int i){for(int j = i - 1; j < n; j++){if(arr[j] == i){arr = swapD(j, arr);c += 2;return j + " " + (j+1) + " ";}}return "";}public static int[] swapD(int p, int[] arr1){int[] arr2 = new int[n];arraycopy(arr1, p+1, arr2, p+1, n-(p + 1));arraycopy(arr1, 0, arr2, 1, p);arraycopy(arr1, p, arr2, 0, 1);for(int i = 0; i < arr2.length; i++)System.out.print(arr2[i]);System.out.println();return arr2;}public static void reverse(final int[] array, final int startIndexInclusive, final int endIndexExclusive){if (array == null) {return;}int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;int j = Math.min(array.length, endIndexExclusive) - 1;int tmp;while (j > i) {tmp = array[j];array[j] = array[i];array[i] = tmp;j--;i++;}}}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
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 |
---|
18210567439 21810567439 32181056749 43218105679 54321810679 ... |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
147533779231220180943085433646... |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
(empty) |