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
77c5b46b76b1f900cb6855ede7e5eb25
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.io.*; public class practice { public static void solve() { Reader sc = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int[] arr = new int[n]; ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
90e9c332a1b27b628f197efd0643e74b
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader sc=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1}; static final double pi=3.1415926536; // static long mod=1000000007; static long mod=9982...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
2396ec81c18f9d75acefb6c649791210
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
/*############################################################################################################ ########################################## >>>> Diaa12360 <<<< ############################################### ########################################### Just Nothing ###################################...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
609739f582de2efd14d91492bdf28fb2
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.io.*; public class A { static Scanner sc; static PrintWriter pw; public static void main(String[] args) throws IOException { sc = new Scanner(System.in); pw = new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int d[]=sc.nex...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
d354694a1c46df9b623dcb61a85e6c04
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class abc { public static void main(String[] args){ Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int x=0;x<t;x++){ int n=scn.nextInt(); int d[] = new int[n]; for(int i=0;i<n;i++){ d[...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
44a4f0f8723cb1537ac06a5bec4e105c
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class B_1739 { public static void main(String[] args) { FastReader sc = new FastReader(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int[] d=new int[n]; int z=0; f...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
bdf8ea0359752ea9e502e0e4429eb963
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class code1 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int tc = sc.nextInt(); while (tc-- > 0) { solve(); } } static void solve() { int n=sc.nextInt(); int[] d=...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f5a8dc61fac7bf5d3f792bde1fb719f3
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Sca...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
638f769df7696ded1c455dee7fa8b90e
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class A { public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } public static String concat(String s1, String s2) { return new StringBuilder(s1).append(s2).toString(); } static long lcm(long a, long b) { r...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
b2dfe068a7a4ae4a8031c7177c04e89e
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; impor...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
bdc2b09db253287cd400b7ba84191368
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t; t = cin.nextInt(); while (t-- > 0) { int n = cin.nextInt(); int a[] = new int[n], ans[] = ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
8d295d6dcd8b18622ff76d2c813e21f5
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solve { static FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] ar...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
57e84cbcebbd2ab419bed3b5a21d2678
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int x=0;x<t;x++){ int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) arr[i]=sc.nextInt(); int a[]=new int[n]; int...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
084d6fb0e0c6937596ae8787a90338e0
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class B_Array_Recovery { static PrintWriter out = new PrintWriter((System.out)); static Reader sc; public static void main(String args[]) throws IOException { sc=new Reader(); int t=sc.nextInt(); while(t-->...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
b91a2bc7d9133273bc9d1189a1b8ad7f
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class codeforces { public static int gcd(int a,int b) { if(b>a) { if (b % a == 0) return a; int c = b % a; return gcd(c, a); } if (a % b == 0) return b; int c = a % b;...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f16fedb78c5c9b58adc08afe51a2d94f
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class CF_136B { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int size = s.nextInt(); int[] arr = new int[size]; for (int i = 0; i < size; i+...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f4f21d001a1927a3acfdb93bb1b5d63d
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(new BufferedInputStream(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
83086a61a7df785a108561ba39b1c554
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class Restore { 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(); int[] d = new int[n]; for (int j = 0; j < n; j++) { ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
30f28a2fb88675cc0f2a27215282eccb
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class Testing { public static void main(String[] args) { Scanner s = new Scanner(System.in); int count = s.nextInt(); int[] d= null; int[] a = null; boolean mult = false; ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
40ae305ea045ff730e861506fb1656e3
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.HashSet; import java.util.TreeSet; import java.util.HashMap; import java.util.Queue; import java...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
338b20e8d8578e2ce82d64f8149420c6
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.math.*; import java.util.* ; import java.io.* ; @SuppressWarnings("unused") //Scanner s = new Scanner(new File("input.txt")); //s.close(); //PrintWriter writer = new PrintWriter("output.txt"); //writer.close(); public class cf { static long gcd(long a, long b){if (b == 0) {return a;}return gcd(b...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
1c54b1d5bf93019df7bb129c2e0f96a1
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.math.*; import java.util.* ; import java.io.* ; @SuppressWarnings("unused") //Scanner s = new Scanner(new File("input.txt")); //s.close(); //PrintWriter writer = new PrintWriter("output.txt"); //writer.close(); public class cf { static long gcd(long a, long b){if (b == 0) {return a;}return gcd(b...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
197635fa5e67eee308c6d951f9de885f
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class Main { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I/O usaing short named function ---------*/ public static String ns() { return scan.next(); } public static int ni() ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
fc2d96a77e78420ec4ff09d156e3b9fb
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
070c4534e2b8f2eb8a6aa2d2bc038974
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; public class abc { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0) ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
cbf949765dcc9f6e21d78563e6b8aa8f
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class Main { // public static void den(int []arr,int i) { // for (int j = 0; j < arr.length-1; j++) { // if(j==arr.length-i) { // break; // } // int temp=0; // temp=arr[j]; // arr[j]=arr[j+1]; // arr[j+1]=temp; // } // ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e2eedc3fb3fcc8d37b57e1346431a809
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String args[]) { Scanner in=new Scanner(System.in); int t=in.nextInt(); testcase: while(t-- >0) { int n=in.nextInt(); int[] d=new int[n], a=new int[n]; for(int i=0; i<n; i++) ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
8347e04d68b2613137d5735e9efb662a
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class Main { //d2 = a2-a1 public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int arr[] = new int[n]; for(int i=0; i<n; i++){ ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
37935575141379aeae28e153c9e3220a
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
//package kg.my_algorithms.Codeforces; import java.util.*; import java.io.*; public class Solution { private static final int[][] knightMoves = {{1,2},{-1,2},{1,-2},{-1,-2},{2,1},{-2,1},{2,-1},{-2,-1}}; private static final FastReader fr = new FastReader(); public static void main(String[] args) thr...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
34669a2e4bffaa1d45ad1c942bb3ccb3
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { new Main().run(); } private void run() { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int count = 0; count < t; count++) { int n = sc.nextInt(); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e5380deadc8f00ea699c1ffb668369d4
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
2122eda5a758ab11bc4c11cb091d9cf5
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.PrintStream; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintStream ps = new PrintStream(System.out); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
54af38bcb88dedbccd9f2fdd47404582
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { FastScanner input = new FastScanner(); int tc = input.nextInt(); work: ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
777b2a7cb489f5e6ee732960b3ba94cd
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class B { static final long...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
943b3ed9167e75ef413d40fc843e17ca
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); int t = ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
4ef5730688ad6d88375b29e8c6a6750f
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class contest2 { public static int sum(int[]arr,int idx){ int s=0; for(int h=0;h<=idx;h++){ s=s+arr[h]; } return s; } public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.next...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
17df6c3dc805513d876aa193d127f0ae
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class CF { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int T=Integer.parseInt(br.readLine()); while(T-->0) { String s=br.readLine(); int n=Integer.p...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
4ee318165b990ed8dd9a15795d42c4c2
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Solution { static MyScanner str = new MyScanner(); // static Scanner str = new Scanner(System.in); public s...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
9ce0157d6465da2fba40a70bfd289b16
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String args[]) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f6a8abe0fa49df505ac49db570c6c99a
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.time.*; import static java.time.temporal.ChronoUnit.MINUTES; import javafx.util.Pair; public class Program { public static void print(Object str) { ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
93264bfeb44bde91253fed34441579e2
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { //nums Scanner scn = new Scanner(System.in); int test_cases = scn.nextInt...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
1a8aa57ff70020100d4a1561defe5024
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuffer output = new StringBuffer(); int T = sc.nextInt(); while(T-- > 0) { int n = sc.nextInt(); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
47254f9610c766a38946fe5c83e9fff0
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class arrayRecovery1100 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int[] d = new int[n]; for(int i=0;i<n...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
0ebff75f7c638507dadacce249b9e1b7
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class B1739 { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int[] d = new int[n]; int[] a = new int[n]; boolean flag = ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
7207c0591bfc90f5e0c1e7379cf9ca34
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { static class Reader { public BufferedReader br; StringTokenizer st = new StringTokenizer(""); public Reader() { this(System.in); } public Reader(InputStream input) { ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
2786fe4785a6acd9c51fc2073677ebc9
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class arrayRecovery { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ///input int t = sc.nextInt(); int[][] testcases = new int[t][]; int index = 0, length = t; while (length > 0) { i...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
23f29a2056601c1f04811bdb53d0e0f6
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.InputStreamReader; import java.util.*; public class Main { static Scanner cin = new Scanner(new InputStreamReader(System.in)); public static void main(String[] args) { int t = cin.nextInt(); for (int i=1;i<=t;i++) { solve(); } } private ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
41c78fb36b2c72f8099cdf58623556cf
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
//package com.rajat.cp.codeforces.edu136; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BArrayRecovery { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
5ff6bcf5779c410ba6c26a4d5a0cbc5b
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
// Online Java Compiler // Use this editor to write, compile and run your Java code online import java.util.*; public class HelloWorld { public static int gcd(int Num1, int Num2){ int Temp, GCD=0; while(Num2 != 0) { Temp = Num2; Num2 = Num1 % Num2; ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
8f8064c5e89bb5d6ae98a5fb9e7bbb08
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.StringTokenizer; public class Main { p...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
75ad07f570d8e017ccf417eba7357f86
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class Main { private static void solve(int n, int[] arr){ int[] res = new int[n]; res[0] = arr[0]; for(int i = 1; i < arr.length; i++){ if(res[i-1] + arr[i] >= 0 && res[i-1] - arr[i]>= 0 && arr[i] != 0){ out...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
b05d79ed7c03c5cd401c4a7b7d142b1a
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.math.*; public class Recovery{ public static void main(String[] args) { Scanner o = new Scanner(System.in); int t = o.nextInt(); while(t-- > 0){ int n = o.nextInt(); int[] a = new int[n]; a[0] = o.nextInt(); boolean more = false; for(int i = 1; i < n; i...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
9a5247446590db6b28de8d1c084db1cf
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; public class B { public static void main(String[]args) throws IOExcept...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
c1bdb77b54db948f3c0638a9ce1e6e8c
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class arrayrecovery { static private final String INPUT = "input.txt"; ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
bd0d9a7048d872243365639383a4d672
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int ii = 0; ii < t; ii++) { int n = in.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e858aaaa1773494d2354269413b9156a
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; public class Solution { public static void main(String args[]){ FastScanner sc = new FastScanner(); int t = sc.nextInt(); while(t-- > 0){ int n = sc.nextInt(); int d[] = new int[n]; for(int i=0; i<n; i++){ d...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
a170e1976339794c097c285f3fce707e
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class EF136 { static Scanner sc = new Scanner(System.in); public static void solve1() { int m = sc.nextInt(); int n = sc.nextInt(); if (m < 4 && n < 4) { m = m / 2 + 1; n = n / 2 + 1; } else { m = n = 1; } System.out.println(m + " " + n); } ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e92a8cf7ee5486395eb784180c225d63
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class HelloWorld { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0){ int n = scan.nextInt(); int[] d = new int[n]; for(int i=0; i<n; i++){ ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
b4421b446e6fb7588789cd48085e9124
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
// Java program to find length of the longest valid // substring import java.util.*; public class A1739 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int tt=0;tt<t;tt++) { int n = sc.nextInt(); int d[] = ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
b99b942494ca417015f28cb927ac84b9
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; import java.util.List; public class Main { static PrintWriter out = new PrintWriter(System.out); static Scanner in = new Scanner(System.in); static BufferedReader re = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter wr = new Buffer...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
6cb9001172867ce600ba6b7b560bb4d0
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; // Map.Entry<Integer,String>dum; //res=(num1>num2) ? (num1+num2):(num1-num2) /* Name of the class has to be "Main" only if the class is public. */ public class Pupil { static FastReader sc = new FastReader(); public static ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
579eaab0a109d1c87e05506d8938ccfe
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class CF1 { static FastReader sc=new FastReader(); // static long dp[][]; // static boolean v[][][]; // static int mod=998244353;; // static int mod=1000000007; static long oset[]; static int oset_p; static long...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
ce1b93382c7d384190260aff63d550d5
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
/* package codechef; // don't place package name! */ import java.io.*; import java.lang.*; import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main(String[] args) throws java.lang.Exception { // your code goes here Sc...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f86ec02521102f426032c065fc5849e6
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
//created by Toufique on 29/09/2022 import java.io.*; import java.util.*; public class EDU_136B { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = in.nextInt(); outer: for (int t...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
f7c63dbc50db924a038cf81593b9d58c
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.HashSet; import java.util.LinkedList; public class Main { static InputReader in; static OutputWriter out; public static void main(String[] args) throws Exception { in=new InputReader(System.in); out=new OutputWriter(System.out); int...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
723747fc4fc402d1b7674c7b43023fb4
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.*; public class B { static class Pair { int f;int s; // Pair(){} Pair(int f,int s){ this.f=f;this.s=s;} } static class sortbyfirst implements Comparator<Pair> { public int compare(Pair a,Pair b) { r...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
c288e624062b3fbeac3f29619cefb751
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Solution { private FastReader reader; private StringBuilder sb; private static final int TEN_POW_FIVE = (int)1e5; private static final int MOD = (int)1e9+7; public Solution() { this.reader ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e40d4f45213c91f04993c700df677e48
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.io.*; import java.util.StringTokenizer; /** * @author freya * @date 2022/9/6 **/ public class B { public static Reader in; public static PrintWriter out; public static void main(String[] args) { out = new PrintWriter(new BufferedOutputStream(System.out)); in = new...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
df1cd2f987b5c90e41cc5c4979f1b7fe
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class c1733 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t,j,i,n,a[],p; //long a[]; t=sc.nextInt(); for(j=1;j<=t;j++){ n=sc.nextInt(); a=new int[n]; for(i=0;i<n;i++) ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
cf24ebb5826f4da833bb1d3688d3ef52
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
//package codeforces.edu136; import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); solve(...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
40ef49570ccfc70a479fcaf90a0963f5
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.Scanner; public class solution { static Scanner sc = new Scanner(System.in); public static void main(String [] args) { int a = sc.nextInt(); for(int i = 0; i < a; i++) { int flag = 0; int num = sc.nextInt(); int [] arr...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
ea987771f9f815664a063f43b770dbc4
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigInteger; import static java.lang.Math.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long t=sc.nextInt(); for(int i=0;i<t;i++){ long n=sc.nextInt(); ...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
e7a20808ba327e87a84c77949158a1ae
train_109.jsonl
1664462100
For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner (System.in); int t=in.nextInt(); // boolean cnt=true; while(t>0) { boolean cnt=true; int n=in.nextInt(); int d[]=new int[n]; for(int i=0;i<n;i++) d[i]=in.nextInt()...
Java
["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"]
2 seconds
["1 1 3 8\n-1\n0 0 0 0 0"]
NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
f4b790bef9a6cbcd5d1f9235bcff7c8f
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ...
1,100
For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.
standard output
PASSED
cc3db398293c8ea525c59d0e1e4b3610
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
// package codeforces; import java.util.Scanner; public class deddazai{ public static void main(String[] args) { Scanner dazai = new Scanner(System.in); int t = dazai.nextInt(); int n, m, x, y, i; for ( i = 0; i < t; i++) { n = dazai.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
fce5bf3a1e4f94127f7ed6bc7cfb1457
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int testCases = scn.nextInt(); for (int i = 0; i < testCases; i++) { int n,m; n = scn.nextInt(); m = scn.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
05e716da37c41b0aab3a3e42d07518ce
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int testCases = scn.nextInt(); for (int i = 0; i < testCases; i++) { int n,m; n = scn.nextInt(); m = scn.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
313e1400b99750b7dbccaa45c6d318db
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
//package com.company; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- > 0){ in...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
2ae170034e3233cc8330d2cc67daefbe
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Knight { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); while(n!=0){ int a=sc.nextInt(); int b=sc.nextInt(); int x=(int)Math.floor(a/2)+1; int y=(int)Math....
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
b8d3ab9ac2f6664ceddd1da848936035
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t--!=0) { long n=sc.nextLong(); long m=sc.nextLong(); if(n==3&&m==3) System.out.println((n-1)+" "+(m-1)); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
4c044653a2a7ee1132079e68fe23be53
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class ImmobileKnight { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = sc.nextInt(); while (t > 0) { int n = sc.nextInt(); int m = sc.nextInt(); if(n == 1 || m == 1) Sy...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
c2181e753ba2791a2afc790424a8836a
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class ImmobileKnight { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int n, m; for (int i=0; i<t; i++) { n = sc.nextInt(); m = sc.nextInt(); if ((n<=3 & m<=3) & (n+m==5 || n+m==6)) System.out.println("2 2")...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
b93ff3f842f9b7dea3dfc494571028ed
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; import java.io.*; import java.lang.reflect.Array; public class problem { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); int min=Math.min(n, m); int max=Math.m...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
a51317d51f45825ec2eaf92a34fcbbb2
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class ImmobileKnight { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); int ro[]={+2,+2,-2,-2,+1,+1,-1,-1}; int co[]={+1,-1,+1,-1,+2,-2,+2,-2...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
3e5188c0d791bd44c1fdfe03b7c18c9e
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; public class ImmobileKnight { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for (int x = 0; x < t; x++) { int n=s.nextInt(); int m=s.nextInt(); if(n==1 || m==1){ ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
ff23212f89d958f036d61b36a66db7fb
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.io.*; import java.util.*; public class syntax { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for(int i = 0; i<t; i++) { int m = scanner.nextInt(), n = scanner.nextInt(); if(m<=2&n<=2)...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
28b71111eb9b32b49ad05c65e49b7de8
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; import java.io.*; public class Main{ private static FastReader sc; private static PrintWriter out; public static void main(String[] args) { sc = new FastReader(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
9d0f589dd0aa3848a85908b64d1cdfd2
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); int m = in.nextInt(); if((n==2 && m == 3) || (n == 3 && m == 2) ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
a1f4035729266a62c75edc2ae20d9bd6
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testCases = sc.nextInt(); for(int i = 0; i < testCases; i++) { int nRows = sc.nextInt(); int mCols = sc.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
2cfe5a035f553a770c039c9b1a487449
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testCases = sc.nextInt(); for(int i = 0; i < testCases; i++) { int nRows = sc.nextInt(); int mCols = sc.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
5d32f1fc3866e3c17ff94559e19d3904
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
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 testCases = sc.nextInt(); List<Integer> results = new ArrayList<Integer>(); for(int i = 0; i < ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
0fbf84944b35c5bb89d30ee646ceda1c
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); int m = in.nextInt(); int cell_n = (n + 1) / 2; ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
24a9aad7163d977fc1e349e2c705d43b
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0; i<t; i++) { int n=sc.nextInt(); int m=sc.nextInt(); if(n==1 || m==1) { System.out.print(n+ " "); System.out.print(m); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
1a85417310e08111bd25468af203e3e9
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Qwerty { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int q = 0; q < t; q++) { int n = scanner.nextInt(); int m = scanner.nextInt(); ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
c956498e665472c511a1d83703690f70
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
//package codeforces; import java.util.Scanner; public class Problem_23 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while (test-- > 0) { int n = sc.nextInt(); int m = sc.nextInt(); if(n == 1 || m == 1) { System.out.println(...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
f9c095630c9f0e8f228ec3740611d418
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class IsolatedHorse { public static Scanner sc =new Scanner(System.in); public static void main(String[] args) { int cases = sc.nextInt(); for(int i = 0; i<cases;i++){ int n = sc.nextInt(); int m = sc.nextInt(); i...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
7410adeb011be7cf5b6cfbb12ce971b9
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class immobile_knight_cf { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int t=sc.nextInt(); while(t--> 0){ int n=sc.nextInt(); int m=sc.nextInt(); if(n == 1 || m ==1) { Syste...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
875817e5e10429052948fddbb660d011
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Konnb { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); if(m==3&&n==3||m==2&&n==3||n==2&&m==3){ ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
ec2367d878c6cd326b8fc5cea58abd7a
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; public class Konnb { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); if(n>=4&&m>=4){ System.out.print...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
b19283b46194fb3fb317764c09530699
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.*; public class decelaration { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0){ int n = sc.nextInt(); int m = sc.nextInt(); if (...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output
PASSED
c35549d8f579359420f63af278ef0530
train_109.jsonl
1664462100
There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell ...
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Solution { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t!=0) { int n=sc.nextInt(); int ...
Java
["3\n\n1 7\n\n8 8\n\n3 3"]
2 seconds
["1 7\n7 2\n2 2"]
NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct ...
Java 17
standard input
[ "implementation" ]
e6753e3f71ff13cebc1aaf04d3d2106b
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.
800
For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.
standard output