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 | 71d57045f88e2e0480e10a6b3f07931a | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcept... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | b7c0b98ca3be36433889c59a4609d0de | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] arr = sc.nextIntArray(n);
if (arr[n - 2] > arr[n - 1]) {
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 32024a6d231a77b700a8db18aec775f3 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class CodeForces {
final static String no = "NO";
final static String yes = "YES";
static public PrintWriter pw = new PrintWriter(System.out);
static public IO sc = new IO();
static Scanner fc = new Scanner(System.in);
//... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 4645cc7c925d8f53db00cdc9269409c4 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.Math.PI;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 1053f2524fcfd03661330607c228c642 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static final int INF = Integer.MAX_VALUE;
static final int NINF = Integer.MIN_VALUE;
static final long LINF = Long.MAX_VALUE;
static final long LNINF = Long.MIN_VALUE;
static Reader reader;
static Writer writer;
static Pr... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 0d0c17735697a3fe565a2f5b54edfab4 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class C {
public void prayGod() throws IOException {
int t = nextInt();
while (t-- > 0) {
int n = nextInt();
long[] a = nextLongArray(n);
if (a[n - 2] > a[n - 1]) {
out.println(-1);
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | f85ad4a80977568199ea50c7762df692 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | /***** ---> :) Vijender Srivastava (: <--- *****/
import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;
public class Main
{
static FastReader sc =new FastReader();
static PrintWriter out=new PrintWriter(System.out);
static long mod... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | a82f990c5898caec67b4ec0821ae716c | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
public class Main {
// static final File ip = new File(... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 8b3527cbaee0e76a59634b8035e57ade | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | // C. Differential Sorting
// Codeforces Round #772 (Div. 2)
// Codeforces
// Solution by Anmol Sharma
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
public static long mod = 1000000007;
public static long mod2 = 998244353;
public static void main(String[] ar... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d2440029ca37b142636212e85d26fb82 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | 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();
int[] arr = new int[n];
boolean sort = true;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 3e8811028825382d04ce63be793c2883 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class C {
static QuickReader fs = new QuickReader();
st... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 98201cc9f708564f5d7e4ad165049028 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class C {
static QuickReader fs = new QuickReader();
st... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 40f504668ac3ddf8daebae5d262595ea | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
// Java is like Alzheimer's, it starts off slow, but eventually, your memory is gone.
import java.io.*;
import java.util.*;
public class Aqueous {
static MyScanner sc = new MyScanner();
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) {
in... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 63f6bd274ea699df55ccd3ef0ac6e026 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //package Codeforces.Round772;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C{
public static void main(String[] args) throws Exception {new C().run();}
long m... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | cab5346815f4b0ee2d4bed7b0205a257 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | // 🔥🔥🔥🔥 Author: Aman Bhatt (Codeforces Handle: bhattaman0001) 🔥🔥🔥🔥 //
import java.io.*;
import java.util.*;
public class Practice extends PrintWriter {
Practice() {
super(System.out);
}
static Scanner sc = new Scanner(System.in);
class Pair {
int first, second;
public P... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | e2d6e65ef4ef1f283d9e7ebdfd6f4fcf | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
public class differential{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int arr[]=new int[n];
// int B[]=new int[n];
for(int i=0;i<n... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | dde04d110ee195e9be694183fb7c5e40 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader(... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 933d960501fcfd57e21c32df4b2c5d51 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class CodeForces {
/*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/
public static void solve(int tCase) throws IOException {
int n = sc.nextInt();
int [] arr = new int[n];
boo... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 4c5fd798bc5f588d410514db5a1a7a89 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | 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();
int[] arr = new int[n];
boolean sort = true;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | ff32db9fd953717e532a96646ac5b2a2 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
public static void main (String[] args) throws IOException {
Kattio io = new Kattio();
int t = io.nextInt();
outer: for (int ii=0; ii<t; ii++) {
int n = io.nextInt();
long[] arr = new long[n];
for (int i=0; i<n; i++) {
arr[i] = io.nextLong();
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 970c0dfd73b271d6dcd422edf454030d | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 6b8fa46db2af0bbabb01b4343b55ddc9 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C_Differential_Sorting {
static final int INT_MOD = (int) 1e9 + 7;
static final long LONG_MOD = (long) 1e9 + 7;
static final int INT_POSITIVE_INFINITY = Integer.MAX_VALUE;
static final long LONG_POSITIVE_INFINITY = Long.MAX_VALUE;
static final int... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 9d1501ad2deeeb7b2a0d8b536e01ebce | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
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();
long[] a=new long[n];
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 9b8f712825c3869c88d268e0bf06edc8 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
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();
long[] a=new long[n];
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 63b7b827feff5c1c2a0e2c3dda8c5805 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.LinkedList;
import java.util.Scanner;
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();
long[] a=new long[n];
for(int i=0;i<n... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | ada360198dcec6bb84d39aa238f02a0a | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static class Data implements Comparable<Data>{
int ind, val;
public Data(int a, int b) {
ind = a;
val = b;
}
public int compareTo(Data o) {
if(val == o.val) return Integer.compare(ind, o.ind);
return Integer.compare(val, o.v... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | fdf91bf367f96322e9a779d97237bb8d | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static class Data implements Comparable<Data>{
int ind, val;
public Data(int a, int b) {
ind = a;
val = b;
}
public int compareTo(Data o) {
if(val == o.val) return Integer.compare(ind, o.ind);
return Integer.compare(val, o.v... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 783d29ffd13e444704081e4b19dd4634 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import javax.print.attribute.IntegerSyntax;
import java.net.CookieHandler;
import java.util.*;
import java.io.*;
//import static com.sun.tools.javac.jvm.ByteCodes.swap;
// ?)(?
public class fastTemp {
static FastScanner fs = null;
static ArrayList<Long> graph[] ;
static int mod = 998244353;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 593bfc371b9a6fa467d30d69b752c859 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import javax.print.attribute.IntegerSyntax;
import java.net.CookieHandler;
import java.util.*;
import java.io.*;
//import static com.sun.tools.javac.jvm.ByteCodes.swap;
// ?)(?
public class fastTemp {
static FastScanner fs = null;
static ArrayList<Long> graph[] ;
static int mod = 998244353;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 0910ac78f703938e15e006201fa38700 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Hiking {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException, InterruptedException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nex... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 349095f9fac193e52e1fd71e345d55b6 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Hiking {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException, InterruptedException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nex... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 08daa74bbeb496db6b42a669cfb99e04 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Hiking {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException, InterruptedException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nex... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 846f54eee9ea75c04134cdc9104f682f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Hiking {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException, InterruptedException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | f2b038fe8030db54bb3502f0f5622959 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
long arr[] = sc.nextlongArray(n);
long maxSum = 0;
boolean f = true;
int y = 0 , z=0;
y= n-2;
z=n-1;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | b31c44d473cc0751309632acd9990fe3 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public final class C {
public static void main(String[] args) {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int T = fs.nextInt();
for(int tt =0; tt < T; ++tt){
int n = fs.nextInt(... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 86ec76f627396f8149979e7cd33be8dc | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
for (int i = 0; i < n; i++) {
int m = scan.nextInt();
int[] arr = new int[m];
for ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | dc7faf115a2b41853a02abae64f1965a | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
Scanner scan = new Sca... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d16d72884d1a3406330f090f5fa87a5b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class C1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i = 0; i < t; i++){
int n = in.nextInt();
long[] arr =... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 5b84b262a2b6da6182bf18c49703c287 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class C {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | c4c3bc593cc76a07f46bf6b1e8311c6e | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class C {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | b85fb8b4530659e6b3b27fb2d92367ed | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.*;
public class Main{
public static void main(String[] args) {
TaskA solver = new TaskA();
// boolean[]prime=seive(3*100001);
int t = in.nextInt();
for (int i = 1; i <= t ; i+... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 6ef0db85dab127c74a8c7ac2f8c7151f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //package codeforces.round772div2;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class C {
static InputReader in;
static PrintWriter out;
public static void main(String[] args) {
//initReaderPrinter(true);
initReaderPrinter(false);
solve(in.nextInt(... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 1522fd05796b68859d5843d2d332973f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
//import java.util.HashMap;
import java.util.*;
public class C {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static Scanner scn = new Scanner(System.in);
public static void main(String[] args) throws Exce... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 1550827af2a7d116aea77c30d37af97e | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer st = new StreamTokenizer(br);
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void mai... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | df4d6d375a3ea0ec3bd0c0770aefa862 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer st = new StreamTokenizer(br);
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 977c060e849cc60753d392eb0b53b67f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer st = new StreamTokenizer(br);
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void mai... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 264dffd4bd74f62c046661c7f1363d58 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.util.ArrayList;
import java.util.Scanner;
/**
* https://codeforces.com/problemset/problem/1635/C
* C. Differential Sorting
* */
public class Main {
static int N = 2 * 100010;
static int[] a = new int[N];
public static void main(String[] args) {
Scanner sc = new Scanner... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 60d6da31e7ba898f7b2a9714a92ef1d6 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class C1635 {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(r.readLine());
for(int i = 0; i < T; i++) {
int n=Inte... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | dea97b7f3c3e294a43bf84376a4f09aa | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.ut... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | df5308e138328e6a897108758ccd0d9b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
//3 6 6 1
//2 7 4 6
public class D {
private static void sport(int[] a) {
int n = a.length;
List<int[]> ans = new ArrayList<>();
bo... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | e26e4a6cb66711b5c3673bd6161b8cfe | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Temp {
static int t,n,arr[];
static final PrintWriter out=new PrintWriter(System.out);
static final StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public static void main(String[] args) throws IOExc... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 604d38a0b81ca5a32246cb0855b397c4 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | b51005b25e51aca9eaffb68149ba115b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.lang.*;
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;
pu... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 2a0d97c3419de63b2edf8029bf8d80c7 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
public class Main{
static PrintWriter out;
static int [] tmp;
static ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 2ebb522efe8813633218d50d1106a6a8 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | // letsgoooooooooooooooooooooooooooooooo
import java.util.*;
import java.io.*;
public class Solution{
static int MOD=1000000007;
static PrintWriter pw;
static FastReader sc;
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastR... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | e347c8ff983ab5cd7d91d221e01075ca | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef {
static long fans[] = new long[200001];
static long inv[] = new long[200001];
static long mod = 1000000007;
static void init() {
fans[0] = 1;
inv[0] = 1;
fans[1] = 1;
inv[1] = 1;
for (int i = 2; i < 200001; i+... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 88402ea0e139fee9326096087827f4e2 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class R772C {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.read... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | a25510d13d578119680f02a3f9f29e63 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static PrintStream out = new PrintStream(System.out);
static LinkedList<LinkedList<Integer>> adj;
static boolean[] vis;
static long ans;
static int target;
static HashMap<ArrayList<Integer>, Integer> seqs;
//static ArrayL... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d35665cba2e6a5ad0adf9f2eef6508ad | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static PrintStream out = new PrintStream(System.out);
static LinkedList<LinkedList<Integer>> adj;
static boolean[] vis;
static long ans;
static int target;
static HashMap<ArrayList<Integer>, Integer> seqs;
//static ArrayL... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 126fb4f4c10adf4794f3823d5cf5c3b2 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
public class class1 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
while(t-->0) {
int n=input.nextInt();
int a[]=new int[n];
int x=0,y=0;
for(int i=0;i<n;i++){
a[i]=input.nextInt();
if(i>0) {
if(a[i]... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 9b473e58152943e748d15bc4ba9cde58 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class cp{
public static void main(String[] args)throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while(t-->0){
int n=Integer.parseInt(br.r... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 57c32c8d3b01f5ee0322e0d85faf6e6c | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
static class Pair{
int i;
int j;
int z;
public Pair(int i,int j,int z)
{
this.i=i;
this.... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 8e6b242b8233c9b38dd112aa3371c967 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int t= sc.nextInt();
while (t-- ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | c580f8fe7937eecd65faf03267561921 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
int inNum = 0;
int n = 0;
int[] num;
Scanner in = new Scanner(System.in);
inNum = in.nextInt();
while(inNum-->0) {
n = in.nextInt();
int[] nums = new int[n];
for(int i=... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d5eb88871a405a9936f80e1dc5d9e65f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.Math;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
public class Main {
static PrintWriter pw;
static Scanner sc;
static StringBuilder ans;
static long mod = 1000000000+... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | addb55b36cb9274d4481a68ca76a4e18 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.io.*;
import java.util.*;
public class C {
static class Pair
{
int f;int s; //
Pair(){}
Pair(int f,int s){ this.f=f;this.s=s;}
}
static class Fast {
BufferedReader br;
StringTokenizer st;
public Fast() {
br = new Bu... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 6ea521ad061df5b41d4aee6ea673d134 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class C {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st;
int t = Integer.parseInt(br.readLine()... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | a2272fa11263f0f90447e26216808617 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.io.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
public class C... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 917ef6009625248383143b4b1680f57b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Codechef {
static FR sc = new FR();
static StringBuilder sb = new StringBuilder();
public static void main(String args[]) {
int tc = 1;
tc = sc.nextInt();
while(tc-->0) {
int n = sc.nextInt();
long arr[] = sc.lon... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 7b52128e11466b09c86406d80e414631 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Main {
static class Reader
{
BufferedReader... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 2b33787d9592479d514695cdf2d3104b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class CodeForces {
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(new FileReader("input.txt"));
PrintStream out = new PrintStre... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 961bb45b263b00027efe2e821a91a170 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import static java.lang.Math.max;
public class main {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int n = input.nextInt();
for (int i = 0; i<n;i++){
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | dedac00c05b39d2809d5524c6a30bbf8 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class a {
public static void main(String[] args){
FastScanner sc = new FastScanner();
int t = sc.nextInt();
StringBuilder ans = new StringBuilder();
while(t-- > 0){
int n = sc.nextInt();
long arr[] = new long[n]... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 545cbf3b48f71b1b1cb6bf68301032bf | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
try{
FastReader read=new FastReader();
StringBuilder sb = new StringBuilder();
long max = (long)Math.pow(10,18);
int t=read.... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 046199d57d2fb6590fd21d8c714412ec | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static class Pair implements Comparable < Pair > {
int d;
int i;
Pair(int d, int i) {
this.d = d;
this.i = i;
}
public int compareTo(Pair o) {
return this.d - o.d;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 8b821e0853ed51ff4409827d152f01fa | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hash... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | db0b546763c3ac113e05ac2967cb35e1 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.rtf"));
PrintStrea... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 1ab1de9bc31398481894f767f81f034a | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.util.stream.LongStream;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args) {
FastReader fr = new FastReader();
PrintWriter out = new PrintWriter(System.out);
Scanner sc= new Scanner (System.in);
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 57a5277204ff0e7daf7d5f744ca85757 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
public class DifferentialSorting {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numTests = sc.nextInt();
for (int test = 0; test < numTests; test++) {
int numElems = sc.nextInt();
int[] arr = new int[numElem... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 1f9e2dd6e8333e334463207ff0a10612 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class DifferentialSorting {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(Sy... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 9d33201160afb43e0ccbc2769b246dc8 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
//import java.text.DecimalFormat;
import java.util.*;
public class Codeforces {
static long mod = 1000000007 ;
public static void main(String[] args) throws Exception {
PrintWrite... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | a17794d4a394c390a09200fd4b4198a2 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Main {
static long cr[][]=new long[1001][1001];
//static double EPS = 1e-7;
static long mod=1000000007;
static long val=0;
public static void main(String[] args)
{
FScanner sc = new FScanner();
//Arrays.fill(prime, true);
//sieve();
//n... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | c97aa68758a8ee85736b6714e5d33a25 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while(t-- > 0)
{
int n = scanner.nextInt();
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 71564a02bc8d1171f4d3b30951c09812 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | // package practise;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
public class A {
static Reader sc;
//static Scanner sc;
static PrintWriter w;
public static void main(String[] args) throws IOExceptio... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 47889e5a3d25e0a60df839ec459ec6e3 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
while(n-->0){
int m=sc.nextInt();
int[] a=new int[m];
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | ec802a9c8e6a77c490212c55d3642136 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class cfc {
FastScanner scn;
PrintWriter w;
PrintStream fs;
int MOD = 1000000007;
int MAX = 200005;
long mul(long x, long y) {long res = x * y; return (res >= MOD ? res % MOD : res);}
long power(long x, long y) {if (y < 0) return 1; ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d58ebab807f8f8347cfe0200eed95b79 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | /*#####################################################
################ >>>> Diaa12360 <<<< ##################
################ Just Nothing ##################
############ If You Need it, Fight For IT; ############
####################.-. 1 5 9 2 .-.####################
###################################... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 6d94a48578e6d35cc138e7d76a50293f | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Rough_Work {
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 566f579efd268606916b680a179d3f47 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = in.nextInt();
for (int tt = 0; tt < t; tt++) {
int n = in.nextInt();
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | b3416229920d88491e9d89464fcdfde4 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //package Competitve1;
//package compete;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.nio.MappedByteBuffer;
//import java.security.acl.LastOw... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 58bc9583393d054362ddda3e0a8b28f6 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //package Codeforces;
import java.io.*;
import java.util.*;
public class C {
static class Pair {
int first;
int second;
Pair(int m, int t) {
first = m;
second = t;
}
Pair() {}
@Override
public String toString() {
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 7f1c687b5b2b42c9b8be0e8ac1c55fdd | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
//import javafx.util.*;
public class Main
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
static ArrayList<Integer> g[];
//static ArrayList<ArrayList<TASK>> t;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 40a20c9fa25f78e367c048149cad0963 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class q3 {
static FastScanner fs = new FastScanner();
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) {
int T = fs.nextInt();
for (int t=0;t<T;t++){
int n = fs.nextInt();
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 521c53cb566d14078c66168b5966039b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class cfContest1635 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
StringBuilder sb = new StringBuilder();
k:
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d7bd66237e9609fbb6cf1ed57ac2823e | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
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 f=0;
for(int i=1;i<n;i++)... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | d7683e6d2245a33e6f71eadcad3dd62b | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | //import java.lang.reflect.Array;
import java.util.*;
import java.lang.reflect.Array;
import javax.print.DocFlavor.STRING;
import javax.swing.Popup;
import javax.swing.plaf.synth.SynthStyleFactory;
public class Simple{
public static class Pair implements Comparable<Pair>{
int val;
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 632f1d2e8065c04ba16f1ff8c8290b9d | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class CodeForces{
public static void main(String[] args) throws FileNotFoundException {
FastScanner fs = new FastScanner();
int t = fs.nextInt();
while(t-- > 0) {
int n = fs.nextInt();
long[] a = fs.readArray(n);
boolean flag = true;
Stri... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 50782a10cdfffce0110a68e242654a66 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | // 😀
import java.util.*;
import java.io.*;
public class C {
static InputReader in;
static PrintWriter out;
static int mod = 1000_000_007;
public static void main(String args[]) {
new Thread(null, new Runnable() {
public void run() {
try {
... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | f30f4bc27435dd4ae25bd1ad9b3fac2d | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.util.*;
import java.io.*;
public class tr0 {
static PrintWriter out;
static StringBuilder sb;
static long mod = (long) 998244353;
static long inf = (long) 1e16;
static int n, l, k;
static TreeSet<Integer>[] ad, ad1, ad2;
static ArrayList<int[]>[] quer;
static int[][] remove, add;
stati... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output | |
PASSED | 6ccdd065d8ac403c7608e15b2e130b75 | train_108.jsonl | 1645367700 | You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to ... | 256 megabytes | import java.io.*;
import java.util.*;
public class cp {
static PrintWriter w = new PrintWriter(System.out);
static FastScanner s = new FastScanner();
static int mod = 1000000007;
static class Edge {
int src;
int wt;
int nbr;
Edge(int src, int nbr, int ... | Java | ["3\n5\n5 -4 2 -1 2\n3\n4 3 2\n3\n-3 -2 -1"] | 2 seconds | ["2\n1 2 3\n3 4 5\n-1\n0"] | NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | c3ee6419adfc85c80f35ecfdea6b0d43 | Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The ... | 1,200 | For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < ... | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.