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
78e8695ba77d66fb68e4c51fa732f5a0
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 < x_i < m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 11
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
858effb09d864b1ca317be053a6fa611
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 < x_i < m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; import java.util.Stack; public class Main { private static final St...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 11
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
68286a98d471785bb90585148e62aae0
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 < x_i < m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.h...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 11
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
a3a01e2599ffaa66d9ad3876a27d1ca5
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 < x_i < m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
/*========================================================================== * AUTHOR: RonWonWon * CREATED: 16.05.2021 13:49:41 * EMAIL: rachitpts.2454@gmail.com /*==========================================================================*/ import java.io.*; import java.util.*; public...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
99ad19b8f8224b34c2dfe1f187304e9c
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 < x_i < m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
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
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
89ec84b7058e24697fd4883cb5389f03
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.lang.*; import java.util.*; import java.io.*; public class Main { static PrintWriter pw = new PrintWriter(System.out); static void deal(int[][] arr,int n,int m) { Arrays.sort(arr,(o1,o2)->Integer.compare(o1[0],o2[0])); LinkedList<Integer> pq0 = new LinkedList<>(); ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
33e3cb03345c88dbec00a289c561247c
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public class C { static class Data{ int val; int Direction; int index; Data(int val, char c, int index) { this.val = val; this.Direction = c; this.index = index; } } st...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
2c566e9462482517a37d012d3a7c6e68
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; //class Declaration static class pair implements Comparable < pair > { int x; int y; pair(int i, int j) { x = i; y = j; } public int compareTo(pair p) { if (th...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
fd1246b71a37d564862837903aeab6d2
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public final class Solution { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static long mod = (long) 1e9 + 7; static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
461406b074916ddd7185472cd07f0fd0
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.util.Map.Entry; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class C { public static void process() throws IOException { TreeMap<Integer, Integer> rightOdd = new TreeMap<Integer, Integer>();...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
a6eea341baa5029012ccf02718afeeb9
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
/* bts songs to dance to: I need U Run ON Filter I'm fine */ import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class x1525C { public static voi...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
35f25a9f67398c61f2fd0fc7d9488b0c
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /*long startTime = System.currentTimeMillis(); //获取开始时间 * long endTime = System.currentTimeMillis(); //获取结束时间 * System.out.println("程序运行时间:" + (endTime - startTime) + "ms"); //输出程序运行时间 */ public class Main{ static final...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
0409dd05f82be3977d0ff011a5e433a5
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
// package FinalGrind; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.Stack; public class Problem1 { static class Reader { ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
a4dedc3d110282206ca357bd634cdea4
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Stack; import java.util.StringTokenizer; public class ProblemC { public static void main(String[] args) throws IOExcep...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
680600dfabe58939773f76d03af14068
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class Pizza { public static void main(String[] args)throws IOException{ PrintWriter out = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLi...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
fc7baa59bb05fa8209cb591f9c47f389
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public class Main { //static final long MOD = 1000000007L; //static final long MOD2 = 1000000009L; static final long MOD = 998244353L; //static final long INF = 500000000000L; static final int INF = 100...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
0d84dd2866ef13d58e84ac57bae404a5
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class Main2 { static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} String next(){while (st == null || !st.hasMoreElements()){try{st = new S...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
759ad6d858ac185b1cede9ece23c6660
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7,mod1=998244353l,inf=(long)1e17; static int[] res; static void go(List<int[]> l,int m){ Queue<int[]> q=new LinkedList<>(); Stack<int[]> ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
11071886c1f6597cd25157fed267ae03
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7,mod1=998244353l,inf=(long)1e17; static int[] res; static int f(int[] a,int[] b){ return a[0]-b[0]; } static void go(List<int[]> l,int m){ ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
77c9b6e9924b5ad5b76bf878608f9cad
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static void main() throws Exception{ int n=sc.nextInt(),m=sc.nextInt(); int[]in=sc.intArr(n); TreeSet<int[]>[]left=new TreeSet[2]; TreeSet<int[]>[]right=new TreeSet[2]; for(int i=0;i<2;i++) { left[i]=new TreeSet<int[]>((x,y)->x[0]-y[0]); ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
a305ba3fb25fea963f020989b3b64599
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class EdA { static long[] mods = {1000000007, 998244353, 1000000009}; static long mod = mods[0]; public static MyScanner sc; public static PrintWriter out; public static void main(String[] havish) throws Exception{ // TODO Auto-generated method stub sc ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
7bf964e95fa28946b80d4e72f764ad34
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public class RobotCollisions_1525C { public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLin...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
8851af896ebbed910d344df24fe94c74
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.net.Inet4Address; import java.util.*; import java.io.*; public class C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
d41867fd9557934be8240228cc3bd07a
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; // res.append("Case #"+(p+1)+": "+hh+" \n"); ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thr...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
b268e72ff0d3569df4b2bd83e1570b97
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
//package com.arnavarora.usaco_prac; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Coll...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
68d2db05c08bc28138c046b862bbaa0c
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; public class Main { // swap() doesn't swap i and j public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); int arr[]=new int[n]; int i...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
bd1876133934d275599451347c5621eb
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuffer out=new StringBuffer(); int t=in.nextInt(); while(t--!=0) { int n=in.nextInt(), m=in.nextInt(); int x[]=new int[n]; for(int i=0; i<n; i++) ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
e17c4e1b982266dde3812102decdf934
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ for(int q=ni();q>0;q--){ work(); } out.flush...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
e0bfd9574b8d0e2f6c923f244cf933cf
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; import java.util.Stack; // https://codeforces.com/contest/1525/problem/C publ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
d2edf89183f0ff037b2b4a9b429419f1
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
8e0ffe54ead5b27997e1e430e955cf48
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.*; public class RobotCollisions { class Element implements Comparable<Element>{ int loc; int idx; char dir; public...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
0fc707ef6db4f039fee43c14401b7413
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class C1525 { 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 m = sc.nextInt(); Ro...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
eae1a51ebf025cf7ea4dc22f696ca094
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuffer out=new StringBuffer(); int t=in.nextInt(); while(t--!=0) { int n=in.nextInt(), m=in.nextInt(); int x[]=new int[n]; for(int i=0; i<n; i++) x[i]=in.nextInt...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
ed26cddb0eeee1073850842c4eab7f1f
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.util.*; import java.io.*; public class Pizza { public static void main(String[] args)throws IOException{ PrintWriter out = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLin...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
859edc444f7f1b9656b05a2133963e45
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
//package codeforce.educational.r109; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
c5923a36a91f0cdb2493676191c55353
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
//------------------>>>>>>>>>>>>>>>> HI . HOW ARE YOU? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<------------------------------ import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.List; import java.util.StringTokenizer; //---------------------------->>>...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
eb52953b585c35ba75ef8b3e763dfc58
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=input.nextInt(); while(T-->0) { int n=input.nextInt(); ...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
dc0a77dfec719633f857eef3fc4e1f32
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= 1000000007; long fac[]= new long[1000001]; lo...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
2ede2f4fdec57a93f60b34379d2ee8a8
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.Stack; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.util.Vector; import java.io.C...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
b310a795aad04ec717bebe7902e3456b
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.AbstractCollection; import java.util.StringTokenizer; import java.io.BufferedReader; import java.uti...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
a8cd83736ade88a22565c93f4ffb81a8
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.lang.*; public class Practice { public static long mod = (long) Math.pow(10, 9) + 7; public static long tt = 0; public static void main(String[] args...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
d702af9a320ce8527cb2e93aa70afd63
train_110.jsonl
1621152000
There are $$$n$$$ robots driving along an OX axis. There are also two walls: one is at coordinate $$$0$$$ and one is at coordinate $$$m$$$.The $$$i$$$-th robot starts at an integer coordinate $$$x_i~(0 &lt; x_i &lt; m)$$$ and moves either left (towards the $$$0$$$) or right with the speed of $$$1$$$ unit per second. No...
256 megabytes
//https://github.com/EgorKulikov/yaal/tree/master/lib/main/net/egork import java.util.*; import java.io.*; public class A{ static PrintWriter out; static InputReader in; public static void main(String args[]){ out = new PrintWriter(System.out); in = new InputReader(); new A(...
Java
["5\n7 12\n1 2 3 4 9 10 11\nR R L L R R R\n2 10\n1 6\nR R\n2 10\n1 3\nL L\n1 10\n5\nR\n7 8\n6 1 7 2 3 5 4\nR L R L L L L"]
2 seconds
["1 1 1 1 2 -1 2 \n-1 -1 \n2 2 \n-1 \n-1 2 7 3 2 7 3"]
NoteHere is the picture for the seconds $$$0, 1, 2$$$ and $$$3$$$ of the first testcase: Notice that robots $$$2$$$ and $$$3$$$ don't collide because they meet at the same point $$$2.5$$$, which is not integer.After second $$$3$$$ robot $$$6$$$ just drive infinitely because there's no robot to collide with.
Java 8
standard input
[ "data structures", "greedy", "implementation", "sortings" ]
1a28b972e77966453cd8239cc5c8f59a
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5$$$; $$$2 \le m \le 10^8$$$) — the number of robots and the coordi...
2,000
For each testcase print $$$n$$$ integers — for the $$$i$$$-th robot output the time it explodes at if it does and $$$-1$$$ otherwise.
standard output
PASSED
bc4f4971f9532341b5c3ac0eacffd7eb
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 D { static final Random random=new Random(); static boolean memory = true; static void ruffleSort(int[] a) { int n = a.length; for (int i=0; i<n; i++) { int oi=random.nextInt(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
6c4041e4e0437e877b2a19b882c81b37
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.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.* ; import java.io.* ; @SuppressWarnings("unused") //Scanner s = new Scanner(new F...
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
7adfae128623abcdb17f21ac91e769d2
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.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.* ; import java.io.* ; @SuppressWarnings("unused") //Scanner s = new Scanner(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
f8a34357313a92e5ea4e83468929476e
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.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.* ; import java.io.* ; @SuppressWarnings("unused") //Scanner s = new Scanner(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
3fbb0f0f986c1a036e5a26efe83b2741
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[]){ FScanner in = new FScanner(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); while(t-->0) { int n=in.nextInt(); int arr[]=in.readArray(n); int copy[]=new int[n]; int c=...
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
bd3e8b515e139be36e6ca2d6327d5f73
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 hw11 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //problem 1 //permutation sort 1525B { int t = scan.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 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
e901d3b089836f1f39746a462c16ee23
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 Problem1525B { public static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int tc = scanner.nextInt(); while (tc-->0){ int size = scanner.nextInt(); int [] array = new int[size]; ...
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
f7f7c88ea387fc47762d97f2886bd895
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 { static boolean checkSorted(int[] a){ for(int i = 0; i < a.length-1; i++) { if (a[i] > a[i + 1]) { return false; } } return true; } 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 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
21ef421cc8d0c02b7ab215c7137c9ab3
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 Exercise { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int testcases = sc.nextInt(); while(testcases-- != 0) { int length = sc.nextInt(); int sort[] = 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
aeb41cde2470c80b9def1ec64acf0684
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 in = new Scanner(System.in); int t = in.nextInt(); while(t-->0){ int n = in.nextInt(); int a[] = new int[n]; boolean flag = true; 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
5e66899d9a768794913d18db93f10e0b
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 testCase = sc.nextInt(); for( int i =0 ;i < testCase ; i++){ boolean oneSorted = false; boolean completeSorted = 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
b82690a8281b828e8e1f1e164491e5f6
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.lang.*; 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 ar[] = 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 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
93b98eb8915cdb61bcc1aef0571f8dae
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.nt.practice; import java.util.Scanner; public class Interface_Test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int T=0;T<t;T++) { int n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.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 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
cf22b74536bfe45532190929864e49c1
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.BigInteger; import java.util.*; public class Stack2 { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { ...
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
3d926a1bd8b07654420df046837934ef
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.lang.*; import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { final static int mod = (int)(1e9 + 7); public static void main(String[] args) { FastReader fs = new FastReader(); int testcase = 1; testcase = fs.nextInt(); while (testcase-- > 0) { solve...
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
ce8d21bc38eedee95a045221f1debfae
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 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 []a = new int[n+1]; int c=0; for(int i=1;i<=n;i++) { a[i]=sc.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 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
be531b8e583fc5648d03e0f087b76a00
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 kriti; import java.math.*; import java.io.*; import java.util.*; public class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); public static void main(String args[])throws IOException ...
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
0c843cde828a4578c1d43c1552683f94
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 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 n = sc.nextInt(); int[] arr = new int[n]; int sum = 0; 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
d8d8bd9f9ec077282d879ff10b91975e
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.math.*; import java.util.Scanner; public class ForTesting { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int test=sc.nextInt(); while(test>0) { 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
c5668b064d6cfad66dbef9df8d470129
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.*; public class PermutationSort { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int runs = sc.nextInt(); while(runs-->0) { int size = sc.nextInt(); int[] arr = new int[size]; int out = 0; boolean sorted = tr...
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
629b31a567dbd20caafc2ec42e395a74
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 New{ 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++) arr[i] = sc.nextInt(); if(isSorted(arr,n)){ System.out.println(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
11c9495d322fc6bc66f829e75d3ad399
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
//WHEN IN DOUBT , USE BRUTE FORCE !!!!!!!!! import java.io.*; import java.util.*; //class Main //AtCoder //class Solution // Codechef public class Solution2 //Codeforces { public static void main(String args[]) { try { FastReader sc = new FastReader(); int TT = sc.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
9723f56547610af292e1189cc19e635b
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 Task{ // ..............code begins here.............. static long mod=(long)1e9+7,inf=(long)1e17; static void solve() throws IOException { int n=int_v(read()); int[] a=int_arr(); int[] b=...
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
2195270849f161514dbaf7567aeb5411
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 // Use this editor to write, compile and run your Java code online import java.util.*; public class HelloWorld { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t--!=0){ int n=sc.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 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
7101550383aa16e4a26eb1d187553b50
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 MyPackage; import java.io.*; import java.util.*; public class MyClass { final static long mod = 1_000_000_007; final static int mini = Integer.MIN_VALUE; final static int maxi = Integer.MAX_VALUE; static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, 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 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
5f5618b73560f82c354741ef5cd9529f
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 Div2_109B { 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++) { 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
4214dc12aca9b55980e7acb50d53d040
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 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i< t; i++) { int n = sc.nextInt(); int a[] = new int[n]; for(int j = 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
f82cc4a547a610c4ab9d9e3f980735b7
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{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0; i<t; i++) { int n=sc.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 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
084bc724b967b880313fa64fe16a93a8
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 A { static final int INF = (int) 1e9 + 9; static final int MAXN = (int) 1e5 + 5; static final int MAXLOG = (int) (Math.log(MAXN) / Math.log(2) + 1e-10) + 1; static final int MOD = 1_000_000_007; static BufferedWriter out = new BufferedWriter(new OutputStre...
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
30ad9a4ec8c43ae94ed6f7cb67106c03
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 static void main(String[] args) throws Exception { FastReader fr=new FastReader(); int t=fr.nextInt(); while(t-->0) { int n=fr.nextInt(); int a[]=new int[n]; int min=Integer.MAX_VAL...
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
f8487344fcd24fe2f443949d637ac1f8
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 BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } static long nextLong() throws IOException {...
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
1b926366015846f0487a22a9bfd4fdc4
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 BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } static long nextLong() throws IOException {...
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
6eb70b49e6dae9c942dcbba01b17b088
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.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.ObjectInputStream.GetField; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; 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 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
68db4c80228c5ee5fa212a4c1fbe82a5
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 B{ static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = sc.nextInt(); while(t--!=0)solve(); } public static void solve(){ int n = sc.nextInt(); int [] arr = new int[n]; boolean mark...
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
a421aba2f6dc9cac975a1440f7c70621
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.lang.*; import java.util.*; public class b { static class FastScanner { InputStreamReader is; BufferedReader br; StringTokenizer st; public FastScanner() { is = new InputStreamReader(System.in); br = new BufferedReader(is); } String next() throws Exception { while (st == null...
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
250c0287d1b61be0676adaf138d22deb
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.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main{ static class FastReader { BufferedReader br; StringTokenizer st;...
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
b845c9b445f36e5b2fcd660099677400
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 second { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElem...
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
4b441c6a2ca03a986d9028151c5af20e
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 New{ 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++) arr[i] = sc.nextInt(); if(isSorted(arr,n)){ System.out.println(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
c8e17a8eaa590cfa27f0c5d05cfde5c7
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 sol{ public static void main(String args[])throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine().trim()); while(t-- > 0){ int n = Integer.parse...
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
e45956520bb5f493610156e2be5caed3
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 MainClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-->0){ int n = sc.nextInt(); int []lst = new int[n]; int diff = 0; b...
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
62dfd62ad89709001afcf7986f02ce5d
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 cf1525B{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int ans = 0; for(int i = 0;i<n;i++){ int length = scan.nextInt(); int[] arr = new int[length]; 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
9b9dfe274540a59dd8d7463549be48a4
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 Project { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int ans = 0; for(int i = 0;i<n;i++){ int length = scan.nextInt(); int[] arr = 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 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
0aad05f2b4539669b050ced5ba962465
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 iScanner = new Scanner(System.in); int test = iScanner.nextInt(); while(test>0){ test--; int n = iScanner.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
31804f9ce460e6bd4e7e4da120712b9e
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.*; import static java.lang.System.currentTimeMillis; /* * @author: Hivilsm * @createTime: 2022-04-27, 23:29:16 * @description: Platform */ public class Accepted...
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
9488e9f20b285c975a888908b0087aec
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.BigInteger; import java.util.*; public class Test { public static void main(String[] args) throws IOException { Reader rd = new Reader(); int t = rd.nextInt(); while (t-- > 0) { int n = rd.nextInt(); int[] a = 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
1b7ae5f41868f86654fce0d3837e8039
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
//CP- MASS_2701 import java.util.*; import java.io.*; public class B_Permutation_Sort { static FastReader in=new FastReader(); static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); public static void main(String args[]) thr...
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
8f8ebd1016cf03612cc84914a509b9c8
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
/* 3 1 2 3 3 1 3 2 3 2 1 3 3 2 3 1 3 3 1 2 3 3 2 1 4 1 2 3 4 4 1 2 4 3 4 1 3 2 4 4 1 3 4 2 4 1 4 2 3 4 1 4 3 2 4 2 1 3 4 4 2 1 4 3 4 2 3 1 4 4 2 3 4 1 4 2 4 1 3 4 2 4 3 1 4 3 1 2 4 4 3 1 4 2 4 3 2 1 4 4 3 2 4 1 4 3 4 1 2 4 3 4 2 1 4 4 1 2 3 4 4 1 3 2 4 4 2 1 3 4 4...
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
8aaaf03c4f20499dd0ee9b1a6f5fde3c
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.PrintWriter; import java.util.*; public class codeforces2 { public static int abs(int x) { if(x<0)return -x; return x; } public static int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } public static void display(char[][]x) { for(int i=0;i<x.length;i++) { 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 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
bb4468336ab8960c98c013d79cf8dfdb
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.Arrays; import java.util.StringTokenizer; import static java.lang.System.out; public class Round109Div2B { public static void main(String[] args) throws Exception { BufferedReader infile = new BufferedRead...
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
5157b11b4ac805a0a23b2a90d1e6c94d
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 class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int 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
85bc2c759694051ae51831bdefcd6f44
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 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]; 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
c45d56fdd5bacd739beb62215b86556a
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 firstjava; import java.util.Scanner; public class tamim { public static void main(String[] args) { try(Scanner cin = new Scanner(System.in)){ int t=cin.nextInt(); for(int i=1;i<=t;i++) { int n=cin.nextInt(); int v[]=new int[55]; int j; for(j=0;j<n;j++) { ...
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
8f2cac7427eb48c2de62a9f3f6ec6c46
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 Justtt; import java.util.*; public class Try { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); Solution s=new Solution(); while(t--!=0) { int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); System.out.println...
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
12a52f5a402da47b0a744e4df0f19c8f
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.*; public class B { public void tq()throws Exception { st=new StringTokenizer(bq.readLine()); int tq=i(); sb=new StringBuilder(1000000); o: while(tq-->0) { int n =i() ; 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
1e15a3d8a1eb3992d947cae031e5a02a
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.*; public class B { public void tq()throws Exception { st=new StringTokenizer(bq.readLine()); int tq=i(); sb=new StringBuilder(1000000); o: while(tq-->0) { int n =i() ; 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
90ae2f0d32b684a8e5fca185ea52da54
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 starting; import java.util.* ; public class Main { public static int solve(int[] nums) { boolean flag = true ; for(int i = 0 ; i < nums.length ; i++) { //System.out.print(nums[i] + " "); if( i+1 < nums.length && nums[i] > nums[i+1]) { flag = 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
b7f61a6b563a71fba6da24ef9e6ae617
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 static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.File; import java.io.PrintStream; import java.io.PrintWriter; import java.math.BigInteger; public class 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 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
ca4cb113c83104ea94a3fbd7e9affc23
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 PermutationSort { public static boolean sort(int a []) { boolean s = false; int b [] = new int [a.length]; for(int i =0;i<a.length;i++) b [i] = a [i]; Arrays.sort(b); if(Arrays.equals(a, b)) s = true; else s = false; return s; } public 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