exec_outcome stringclasses 1
value | code_uid stringlengths 32 32 | file_name stringclasses 111
values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18
values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1
value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27
values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5
values | prob_desc_input_from stringclasses 3
values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3
values | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | 0d38d0ceac68980d0b8aca9ed6549c53 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class FastIO{
BufferedReader br;
StringTokenizer st;
public FastIO(){ // constructor
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while (st == null || !st.hasMoreElements()... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d154b0237e315e20c44566a1fb1feed2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.Collections;
import java.util.Arrays;
public class Main
{
public static boolean isSorted(Integer[] a)
{
for (int i = 0; i < a.length - 1; i++)
{
if (a[i] > a[i + 1]) {
return false;
}
}
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d8828dc6b8f5ee73489eb566867bf479 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- != 0){
int n = s.nextInt();
int arr[] = new int[n];
int safe[] = new int[n];
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ba8d8d58848f4fca6b418ac456d32c8a | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class B_Permutation_Sort {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main (String[] args) throws java.... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | de191b7b1d6f781e1186feffca2b902b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Test{
static int nstep(int a[]){
int max = a[0]; int min =a[0];
for(int i=0;i<a.length;i++)
{ if(a[i]>max){max=a[i];}
else if(a[i]<min){min=a[i];}
}
if(a[0]==max && a[a.length-1]==min){return 3;}
else if... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3ea18e3270804a319f35529500db400d | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /* 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
{
// your code goes here
Buf... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 884af21798150d47e29b95f05ee554c9 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner (System.in);
int t=sc.nextInt();
while(t--!=0){
int n=sc.nextInt();
int[] a=new int[n];
int[] b=new int[n];
int ssc=0,p... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 222a46ff4a59fd4983ad80ae89546da0 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.lang.*;
// import java.math.*;
import java.io.*;
public class Main
{
public static int mod=(int)Math.pow(10,9) + 7;
public static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter ot=new PrintWriter(System.out);
pub... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3713b812de04886bcb1aa71df993251e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static int find(int n,int m,int a[][]){
int dp[][]= new int[n][m];
dp[n-1][m-1]=1;
boolean f=true;
for (int i=m-2;i>=0;i--){
if (a[n-1][i+1]==1&&f){
dp[n-1][i]=1;
}
else{
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 72ae59f67efb9a3bbe0399a0017f6c04 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.*;
import java.io.*;
public class B{
static long x=1000000000+7;
public static FastReader sc=new FastReader();
public static PrintWriter out = new PrintWriter(System.out);
public static void taskSolver() {
int n = sc.nextInt();
int arr[] = new int[n];
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7db089f53f532f45797e35a6037b7597 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.List;
import java.util.Collections;
import java.util.Map;
i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3fde776b3b06dd4d7dde5b6326221eb6 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pranay2516
*/... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 8f488f27752999a4adb0202446257d2e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.Math;
public class Main {
static PrintWriter pw;
static Scanner sc;
static StringBuilder ans;
static long mod = 1000000000+7;
static void pn(final Object arg) {
pw.pri... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | b5703c7bca51245d8cff2ca13a9ccee4 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class B
{
public static void main(String[] args) throws IOException
{
//StringBuffer sb=new StringBuffer("");
int ttt=1;Scanner sc=new Scanner(System.in);
ttt =sc.nextInt();
outer: while(ttt-->0)
{StringBuilder ab=new ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bf874e5d3655877d5cdec5986987deee | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
// 4 3 2 1
// 2 3 4 1
// 2 3 1 4
// 3 2 1
public class CDFB {
private static void solve(int[] a) {
int n = a.length;
int[] c = new int[n];
for (int i = 0; i < n; i++) {
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 6d32145c2145faa75eab78e41f0f8921 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeSet;
import java.util.Iterator;
public class First {
public static void main(String[] args) {
FastSc... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 33e891d750f928dc586b0fd5026b0d39 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
public class permsort
{
static int find(int a[])
{
int n = a.length;
boolean flag = true;
for (int i=0; i<n; i++)
{
if (a[i]!=i+1)
{
flag = false;
break;
}
}
if ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 83f8c388317e4348486c211fb1df70f8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class gfg {
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException{
Reader.init(System.in);
int t = Reader.nextInt();
while(t-->0){
solve();
}
out.close();
}
// static int n =0,m=0;
static... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ab0fddc08eda6512e09a7b09d9dcaed1 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class AiseHi {
static Scanner sc = new Scanner(System.in);
static int mod = (int)(1e9+7);
public static void main (String[] args) {
int t = 1;
t = sc.nextInt();
z : while(t-->0) {
int n = sc.nextInt();
int a[] = new int[n];
in... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 6de3a56b51ffb38f73f33601e008ca0b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.math.BigInteger;
//import javafx.util.*;
public final class B
{
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
static ArrayList<ArrayList<Integer>> g;
static long mod=(long)(1e9+7);
static i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 581b876cf9642ff7daf58b4eacaaf715 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
public class cf1525Bhw4 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int l = 0; l<t; l++){
int n = scan.nextInt();
boolean iszero = true;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | e0bac48d791350107a1574802ba7c4e8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
public class cf1525B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
// int[] arr = new int[n];
// int counter = 0;
//
// for (int i = 0; i < n; i++) {
// ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 22e9127ee16c02319b181f9a704b89a3 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;
public class Permutation_Sort
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStr... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ef69c528ec8b4174a06f0287c7555213 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class cf1525B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int i = 0; i < t; i++) {
int n = scan.nextInt();
int counter = 0;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 58dd0d59cd701402cb56aa5352588268 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter o = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int a[] = new int[n];
for (in... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | e7bb9a7a941dd0dd64c409ac1bfcf443 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] a = new int[n+1];
int ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2db077851d3fdd1c3503702d48e18d1e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = in.nextInt();
for (int t1 = 0; t1 < t; t1++) {
int n = ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 88a55ff91385e4f7f20ec31e544fa313 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.*;
public class helloWorld {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int testCase = 1;
testCase = sc.nextInt();
while(testCase-- > 0) {
int n = sc.nextInt();
int [] array = new int[n];
for(i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bf24feb3c780c2c83478247f2351c326 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
//import javafx.util.*;
public class Solution
{
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static int INF = Integer.MAX_VALUE;
static int NINF = Integer.MIN_VALUE;
public static void main (String[] arg... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 39d702add7ef83cb0ea6f096c82fc3bb | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static class Pair implements Comparable < Pair > {
int d;
int i;
Pair(int d, int i) {
this.d = d;
this.i = i;
}
public int compareTo(Pair o) {
return this.d -... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 6b2c4e6330495c62e960e805a9cfd5a2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class PermutationSort{
static long mod = 1000000007L;
static MyScanner sc = new MyScanner();
static void solve() {
int n = sc.nextInt();
int arr[] = sc.readIntArray(n);
boolean flag = true;
for(int i = 0;i<n-1;i++){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 458450d800623113e704cd2f4069f673 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args) {
// TODO Auto-generated method stub
FastScanner fs=new FastScanner();
int t=fs.nextInt();
while (t-->0... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2b384e71114ad7d91effa3460095fc40 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-->0) {
int n = sc.nextInt();
int ar[] = new int[n+1];
boolean flag=false;
for(int i=1;i<=n;i++) {
ar[i]=s... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7f198e5061064dda54c156c7e29a95cf | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class Permutation_Sort{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int tests = scanner.nextInt();
int size = 0;
bo... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ce6beb09fe4e70e79344560960722fb4 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import static java.lang.Math.*;
import java.io.*;
public class S {
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int test = Integer.parseInt(br.readLine());
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c1d5c8092fac9c4aef3c8e6b8e737e4b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class PermutationSort {
private static final Scanner SCANNER=new Scanner(System.in);
public static void main(String[] args){
int testcase=SCANNER.nextInt();
while (testcase-->0){
int length=SCANNER.nextInt();
int[] array=new int[len... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3d47d96c85b16c46ea290938d69e9d97 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Permutation_sort
{
int noO(int arr[],int n,int max,int min)
{
int flag=0;
for(int i=1;i<n;i++)
{
if(arr[i]<arr[i-1])
{
flag=1;
break;
}
}
if(flag==0)
return 0;
else
{
if(arr[0... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 197082c2728a5530f471e6d6d374f2ec | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class snippe{
static void print(String s){
System.out.println(s);
}
static void print(int s){
System.out.println(s);
}
static int[] rep(int[] arr,int n){
Scanner sc=new Scanner(System.in);
for(int i=0;i<n;i++){
arr[i]... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c9077fb0650f7ab5793cb2db41adbe58 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.Scanner;
public class p1525B {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-->0){
int n = in.nextInt();
boolean sorted = true;
boolean minDisplaced = false;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3ae97a79e2bd0e041361e47f6b3982d7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B extends Driver {
public static void main(String[] args) {
new B().run();
}
@Override
p... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | b5d1112f480de26a414c0e3f38225cec | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class P1525B {
private static FastScanner in;
public static void main(String[] args) {
in = new FastScanner();
int n = in.nextInt();
for (int i = 0; i < n; i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 4374a11dd7bde3d62e0db79dc4a080a1 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class _1525B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++)
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 952a2dc26225b800027fd954d84ed613 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | // package codeforces;
import java.util.*;
public class permutation_Sort {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while (t-- > 0) {
int n = scn.nextInt();
int[]arr=new int[n];
boolean b=false;
for(int i=0;i<n;i++) {
arr... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 48100cc5c7d3ef61b1aa6f8a8801de04 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Test {
static boolean issorted(int[] arr) {
for(int i=0;i<arr.length-1;i++) {
if(arr[i] > arr[i+1]) {
return false;
}
}
return true;
}
static int permute(int[] arr, int count, int n) {
if(issorted(arr)) {
return count;
} else {
if(arr[0] ==... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 75a17989e76f1396159e4564becaa7d2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
public class Solution {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer("");
String next() {
if (!st.hasMoreToke... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3e4e94c0687f6eeee4dadc99bef32407 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import s... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 55a2b1bc8367604534d6688325d4ea6e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class B {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next() {
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 732698706b232dfcdfedb6328ad150f8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class CF_1525b{
public static final void main(String[] args){
Scanner s= new Scanner(System.in);
int t= Integer.parseInt(s.nextLine());
for(int ti=0; ti<t; ti++){
int k= Integer.parseInt(s.nextLine());
String[] arr= s.nextLine... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 35e63b8291ae0809a4a5bdac5c57fc4b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static long gdc(long a, long b) {
if (b > a) {
long t = a;
a = b;
b = t;
}
while (a % b != 0) {
long t = ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 1df5dbd47c76232bef4c2b23922cd8a1 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
/**
*
* @author eslam
*/
public class PermutationSort {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for (int i = 0; i < t; i++) {... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 22c15886e03cee2be61c2f97b7918368 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class codeforce{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
if(test>=1 && test<=2000){
int t=0;
while(t<test){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 58139d2ded35308d7531c490669e2e76 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | //package codeforces;
import java.util.Scanner;
public class PermutationSort {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int arr[]=new int[n];
i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | b099d1ff466fbf536ed148b8ad8c04b2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.io.File;
import java.io.*;
import java.util.*;
public class Main {
// static final File ip = new File("input.txt");
// static final File op = new File("output.txt... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2345dc0fbf46a2df0d7a03c3b44ae7f7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.io.File;
import java.io.*;
import java.util.*;
public class Main {
// static final File ip = new File("input.txt");
// static final File op = new File("output.txt... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bf6384e0a46d94b8833d32996cc03089 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public final static FastScanner fs=new FastScanner();
public static void main(String[] args) {
int t = fs.nextInt();
while (t-- > 0) solve();
}
private static void solve(){
int n = fs.nextInt();
int[] arr = new int[n];
int ans = 2;
for(int ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | fa5a542aec89151306bf04643a8c8066 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Solution {
private static final int MOD = (int) (1e9 + 7);
public final static FastScanner fs=new FastScanner();
public static void main(String[] args)... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | eab21c932d1897e7a7d45f6875b62c67 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class main{
public static void main(String[]args){
Scanner s=new Scanner(System.in);
int t=s.nextInt();
for(int j=0;j<t;j++){
int n=s.nextInt();
int step=0;
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=s.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7b1ba8d3aa0e8b64a4f9e1d902abf989 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.PrintStream;
import java.util.Scanner;
public class Task {
static Scanner input = new Scanner(System.in);
static PrintStream output = new PrintStream(System.out);
static int[] a = new int[50];
public static void main(String[] args) {
int t = input.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d17b765adead87444cb2942a321fc411 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.PrintStream;
import java.util.Scanner;
public class Task {
static Scanner input = new Scanner(System.in);
static PrintStream output = new PrintStream(System.out);
static int[] a = new int[50];
public static void main(String[] args) {
int t = input.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 484a02d9d2177c8aa87cf8bdcf14ed1d | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.PrintStream;
import java.util.Scanner;
public class Task {
static Scanner input = new Scanner(System.in);
static PrintStream output = new PrintStream(System.out);
static int[] a = new int[50];
public static void main(String[] args) {
int t = input.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | a3b36a7473aa1686a19142b209ee80e9 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.PrintStream;
import java.util.Scanner;
public class Task {
static Scanner input = new Scanner(System.in);
static PrintStream output = new PrintStream(System.out);
static int[] a = new int[50];
public static void main(String[] args) {
int t = input.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | a86220e9ba787813b1408ff87c746492 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
***********************************************... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 338ea26125fcccd27003ddb463ea1a6e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class test
{
public static void main(String [] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int k =0;k<t;k++)
{ int n = sc.nextInt();
int a [] = new int[n];
int ans =0;
for(int i =0;i<n;i++)
a[i] = sc.next... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 1524a10cfddd429739cf3f7cf252eaab | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int counter = 0;
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
if (t >= 1 && t <= 2000)
{
for (int i = 0; i < t;... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 1a209b96e3a3965deac922e8eec3907a | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class Solution{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int ts=sc.nextInt();
while(ts-- > 0){
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ba467b5c79d88d049e05aafaddc2d349 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class B {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String ne... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 99871e5664024972fb8d500e5c9e72fd | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | //package codeforces;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class contest {
static class Reader { // Code for Reader class taken from DSA Course reference
static BufferedReader reader;
stati... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | f6a96913945f2b1dce04eacf3875fc12 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 10d51724020b5a4bed31ae8cb768b7fe | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
/*Author Adityaraj*/
import java.io.*;
import java.util.*;
import java.math.*;
public class Template {
// static int count = 0 ;
public static void main(String[] args) throws IOException {
long start = System.nanoTime();
// initialize the mod variabel of very big prime number
final int mod = 1000... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 662a791b7669c79de6086bb37171b11e | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Template {
static int mod = 1000000007;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int yo = sc.nextInt();
while (yo-- > 0) {
int n = sc.nextInt();
int[] a =... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 0f65979354623a2562b83f86f656f48f | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Template {
static int mod = 1000000007;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int yo = sc.nextInt();
while (yo-- > 0) {
int n = sc.nextInt();
int[] a =... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 51dc4ea0c2c618b12ad44529f335bcc6 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer st=new StreamTokenizer(br);
static int nextInt() throws IOException
{
st.nextToken();
return (int)st.nval;
}
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | e7c7b9cfa786c3f5ba0c6a4eae1941f0 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class PermutationSort {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t= sc.nextInt();
while(t>0){
int n = sc.nextInt();
int[] arr=new int[n];
int temp=0;
for(int i=0;... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2cfa12b0cdddbee9a05758d5c73e5f22 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class A{
static FastReader scan=new FastReader();
public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
static LinkedList<Integer>edges[];
// static LinkedList<Pair>edges[];
static boolean stdin = true;... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | f2ec771e37935d469b1a8f86b63e4d66 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.IOException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7a012a87a6cc7944154a18ded01d51d4 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
public class Main {
// private static int dp[][][];
// pri... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d4fa2bc09d857698e842434467502245 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
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
{
FastReader ob = new FastReader();
int t = ob.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 97e5cd79d9fc779722f8743db8741463 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private Spa... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 506eebf31273ea9cc227cf16fbad0552 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Valid_Path {
static int mod=(int)(1e9+7);
public static int gcd(int a,int b){
if(a==0)
return b;
else
return gcd(b%a,a);
}
public static void main(String arg[])throws IOException{
BufferedRea... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 1ccbb28a521a5afe91c648eb9e7632f7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new Bu... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ccc121a3b4d66ce8bf5045418171efe9 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.*;
import java.util.*;
public class GFG {
public static void main (String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int[] arr=ne... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 064024b092091a56474d2277af6d0333 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
/*
author : Multi-Thread
*/
public class B {
// static int INF = 998244353;
static int INF = (int) 1e9 + 7;
static int MAX = Integer.MAX_VALUE;
static int MIN = Integer.MIN_VALUE;
public static void main(String[] args) {
int test = ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 856c8f3aca74967844b418656829640a | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class B_Permutation_Sort{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases = scan.nextInt();
while(testCases-->0){
int length = scan.nextInt();
int[] vals = new int[length... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 72c09de342c93b1e914274cf6dcdcef7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class B_Permutation_Sort{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases = scan.nextInt();
while(testCases-->0){
int length = scan.nextInt();
int[] vals = new int[length... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bbb09ea5e2c5d78378b11dec5f83f73a | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Two {
public ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7ae034f17a2813b922b97a17b619f10b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution{
//fast input output method
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ccb464b0239ecd319a460219e048ffd8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Solution{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int t = input.nextInt();
while(t>0){
int n = input.nextInt();
int[] arr = new int[n];
int[] brr = new int[n];
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c742cd5216fc64869ac15db96a5af8ae | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | //package com.codewithak;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static Scanner myObj = new Scanner(System.in);
public static void main(String[] args) {
// write your code here
// System.out.println("hello world");
// Scanner m... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 89b4aec460be1b0fb7a68a4958d8c257 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.Math.PI;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 48a68a29535e315b971cd89d1ccc45cd | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 9d12b86bdc9b7071a7f66af123ed8916 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class A{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- > 0){
int n = s.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++){
arr[i] ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3f157ec03b859afbf2766852570c592d | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class A {
static boolean isSorted(int arr[]){
for(int i=0; i<arr.length-1; i++){
if(arr[i]>arr[i+1]){
return false;
}
}
return true;
}
static int solve(int arr[], int n){
if(isSorted(arr)){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | aa705ba511f31e88de1d6d92fb6d5a11 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution {
private static final FastReader reader = new FastReader();
private static final PrintW... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 9a4a37ae53838df8b411ea50afb718d0 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /*
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀⢠⠞⠉⠙⠲⡀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀⡏⠀⠀Y⠀⠀⢷
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀⢸⠀⠀A⠀⠀ ⡇
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀⣸⠀⠀S⠀ ⡇
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀⢹⠀⠀H⠀⠀ ⡇
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀⡇⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀⠘⠤⣄⣠⠞⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿………⣀⣰⣏⣘⣆⣀⠀⠀
*/
import java.io.BufferedReader;
imp... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 4122b9b3821c882d50166c407165a2bd | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class B_Permutation_Sort{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 0e5ba815d76d6b8ed23c760e9a6337ca | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
input.nextLine();
for(int i=0; i<t; i++)
{
int n = input.nextInt();
input.nextLine();
int[] arr ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 0f1edaa17af0aafc656e43d298c66ad8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
//Scanner input = new Scanner(new File("psort.in"));
int t = input.nextInt();
input.nextLine();
for(int i=0; i<t; i++)
{
int n = ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 61b633ee2a544ecbea1ac03aa7b83357 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
// Compiler version JDK 11.0.2
public class Dcoder
{
public static void main(String args[])
{
Scanner sc =new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int[] a =new int[n];
for(int i=0;i<n;i++)
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | af392ee3cb83eae59f857e34ebb252ee | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int a = sc.nextInt();
ArrayList<Integer> arrayList =... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 5057307942e078d81321fe9e7a999bbf | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.math.BigInteger;
import java.util.Arrays;
import javax.lang.model.util.ElementScanner6;
public class Main {
static fi... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.