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
7bbc722978be15b48a9e134a27f07432
train_001.jsonl
1416238500
A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the i-th rest point the distance from the start equals xi, and its picturesqueness e...
256 megabytes
/** * Created by ckboss on 14-11-22. */ import java.util.*; public class CF489E { int n,l; class Point{ public int x,b; } Point[] p = new Point[1100]; double[] dp = new double[1100]; int[] pre = new int[1100]; boolean check(double L){ Arrays.fill(dp,-1e8); Arrays...
Java
["5 9\n10 10\n20 10\n30 1\n31 5\n40 10"]
1 second
["1 2 4 5"]
NoteIn the sample test the minimum value of relative total frustration approximately equals 0.097549. This value can be calculated as .
Java 7
standard input
[ "dp", "binary search" ]
9ea7a7b892fefaaf8197cf48e92eb9f1
The first line of the input contains integers n, l (1 ≀ n ≀ 1000, 1 ≀ l ≀ 105) β€” the number of rest points and the optimal length of one day path. Then n lines follow, each line describes one rest point as a pair of integers xi, bi (1 ≀ xi, bi ≀ 106). No two rest points have the same xi, the lines are given in the orde...
2,300
Print the traveler's path as a sequence of the numbers of the resting points he used in the order he used them. Number the points from 1 to n in the order of increasing xi. The last printed number must be equal to n.
standard output
PASSED
fba224f0f8f179e92dc19d684586ff75
train_001.jsonl
1416238500
A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the i-th rest point the distance from the start equals xi, and its picturesqueness e...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Linked...
Java
["5 9\n10 10\n20 10\n30 1\n31 5\n40 10"]
1 second
["1 2 4 5"]
NoteIn the sample test the minimum value of relative total frustration approximately equals 0.097549. This value can be calculated as .
Java 7
standard input
[ "dp", "binary search" ]
9ea7a7b892fefaaf8197cf48e92eb9f1
The first line of the input contains integers n, l (1 ≀ n ≀ 1000, 1 ≀ l ≀ 105) β€” the number of rest points and the optimal length of one day path. Then n lines follow, each line describes one rest point as a pair of integers xi, bi (1 ≀ xi, bi ≀ 106). No two rest points have the same xi, the lines are given in the orde...
2,300
Print the traveler's path as a sequence of the numbers of the resting points he used in the order he used them. Number the points from 1 to n in the order of increasing xi. The last printed number must be equal to n.
standard output
PASSED
ee9118e09bab37f58ae58fec8c2348a8
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
3059ea095ab9fa854226076ede558e5b
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class codeforces { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
9078a758607b91a8a71d2ee7d8059917
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class Forsolving { public static void main(String[] args) { Scanner enter = new Scanner (System.in); int n = enter.nextInt(); System.out.println(n); for(int i = 1; i < n ; i++) System.out.println(i+" "); } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
b3701335f91a3f7d87804f6ed5bb610e
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class Forsolving { public static void main(String[] args) { Scanner enter = new Scanner (System.in); int n = enter.nextInt(); System.out.print(n+" "); for(int i = 1; i < n ; i++) System.out.print(i+" "); } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
632d198da9a5e26c0f5b6bab4c16a4d3
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; public class problem { static void p(int num) { if(num >= 1) { System.out.print(num+" "); for(int i = 1 ; i < num ; i++) { Sys...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
ae07eb39654366f0fee7cf26d48b79e8
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
e6b777128b9ede6b01556a7d6ce2b15e
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class LittleElephantAndFunction { public static void main(String[] args) { out = new PrintWriter(new BufferedOutputSt...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
dccb411ef6cec32809b962667d50bbaf
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(); out.print(n); for (int i = 1; i < n; i++) out.print(" " + i); ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
fb5eb89ac28a0387cee5b29b47ee4fec
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputSt...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
c045e8a85d0a8e7f762b45e041e5bd04
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public final class Scratch { public static void main(String[] args) { Scanner input=new Scanner(System.in); printNumbersAsc(input.nextInt()); } private static void printNumbersAsc(int n) { System.out.print(n + " "); for (int i =1; i<n; i++ ){ ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
d6c60e93e46cd281af8f49b5f340f710
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; public class A221 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); StringBuffer ans = new StringBuffer(); for (int i = 0; i < n; i++) { int cur = (i) % n; if (cur == 0) { cur = n; } ans.append(cur + " "); } ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
e338ec34342cb946b57a89ee3968fb28
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); System.out.print(n); for (int i = 1; i < n; i++) System.out.print(" " + i); input.close(); } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
7fa533babf015d668539828b051e3d46
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class CF_221A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); System.out.print(n); for(int j=1;j<n;j++) { System.out.print(' '); System.out.print(j); } System.out.println(); } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
1172772f101f0f4df8e1c53f315c7cce
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P221A { int [] a; void sort(int n) { if (n == 0) { return; } a[n - 1] ^= a[n]; a[n] ^= a[n - 1]; a[n - 1] ^= a[n]; sort(n - 1); } public void run()...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
32012cf53c685f6dea3d2f1b0ee43ae4
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P221A { public void run() throws Exception { int n = nextInt(); print(n + " "); for (int i = 1; i < n; print(i + " "), i++); } public static void main(String... args) thr...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
687957cd3a3ff5694572d9af7fb0085b
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
4690d81dde315dd9bd47d4fe4b6cee97
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
6e09e30a544fd1232fc27249ee0647d1
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner in = new Scanner (System.in); int n = in.nextInt(); System.out.print(n + " "); for (int i = 1; i < n; ++i) System.out.print(i + " "); } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
90a4e1dc138ed400a8a03e988c256deb
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Comparator; import java.util.PriorityQueue; import java.util.*; import java.util.Scanner; /*f */ //-----------------------------------------------------------------------------------...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
4cd39020077ca642bb35689c95ba7868
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Spandan Mishra */ public class Main { public static void main(String[] args) { InputStream inputStream = System...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
086a793b421ee4180ff8b50cea2faf57
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class Binarysearch { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); System.out.printf("%d%s",n,(n==1)?"\n":" "); for(int i=1;i<=(n-1);i++){ System.out.printf("%d%s",i,(i== n-1)?"\n":" ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
b04f8083b71946e2eae2cd5d3b8673f4
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class LittleElephantandFunction { public static void main(String[] args) { Scanner z=new Scanner(System.in); int n=z.nextInt(); int[] a=new int[n]; while(n>=1){ a[n-1]=n; n--; } int temp=0; for(int x...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
82f4429f9c7272b1c8f487eab9c6d6e0
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class LittleElephantandFunction { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); int[] a= new int[n]; for(int i=0;i<n;i++) { a[i]=i+1; } System.out.print(a[a.length-1]+" "); for(int i=0;i<n-1;i++) { System...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
a472a98b305e1665f5bfe65934a2fca2
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class LittleElephantAndFunction { public static void main(String[] args) { out = new PrintWriter(new BufferedOutputS...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
542ec10f61d904b952a25507ef85f028
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.lang.*; public class P221A{ static long mod=1000000007; public static void main(String[] args) throws Exception{ InputReader in = new InputReader(System.in); PrintW...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
eea64ec9efb7bea251fd7212815cdab9
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class LittleElephantAndFunction { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int permutationCount = Integer.p...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
43fa7f6d0cf181e476893356ea5d83fd
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class a { public static void main(String[] arg) throws IOException { new a(); } public a() throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); out....
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
47e99cfcaa38aaad9e4004d6b9b5401f
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; import java.io.*; public class Q2A { // main method public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int n =sc.nextInt(); System.out.print(n+" "); for(int i=1;i<...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
4f10e225be8d495aed36ac714cf3f65b
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; public class LittleElephantFunction { static Scanner scn = new Scanner(System.in); public static void main(String[] args) { helper(); } public static void helper() { int n = (int)input(); print(n + " "); for (int i = 1; i < n; i++) print(i + " "); print(); } public static l...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
55713e2a8dab89673ae08f0873473510
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class LittleElephant { public static void main(String arg[]) { Scanner sc=new Scanner(System.in); StringBuilder sb=new StringBuilder(); int n=sc.nextInt(); if(n==1) { System.out.println("1"); return; ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
84aaa37a4951c3ddb940e9b4e9d347ba
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; import java.lang.*; import java.text.DecimalFormat; import java.text.NumberFormat; import java.io.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new In...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
bca334f177c6d2089668e485f57f3c78
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.lang.*; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
51c18259c021a142fe8a345649694cd8
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.*; public class j { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); System.out.print(n+" "); for(int i=1;i<n;i++) System.out.pri...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
1f168d6d2c5b35908457fe6e589e3035
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.*; public class TRISQ { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); System.out.print(n); for(int i=1; i<n;i++){ System.out.print(" "+i); } } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
bce201434141e72e582b67351fad63be
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
2c8ac34a801ac639e324f572f9b3c1dd
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.math.BigInteger; import java.util.Array...
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
e9549b8f6e105766d23ac9d069645f63
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class LittleElephantandFunction221A { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n =sc.nextInt(); System.out.print(n+" "); for(int i=1;i<n;i++) { System.out.print(i+" "); } } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
9e076e0a012aadda9420287f52560e83
train_001.jsonl
1346427000
The Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows: If x...
256 megabytes
import java.util.Scanner; public class LittleElephantandFunction { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); System.out.print(n+" "); for(int i=1;i<n;i++) { System.out.print(i+" "); } } }
Java
["1", "2"]
2 seconds
["1", "2 1"]
null
Java 8
standard input
[ "implementation", "math" ]
d9ba1dfe11cf3dae177f8898f3abeefd
A single line contains integer n (1 ≀ n ≀ 1000) β€” the size of permutation.
1,000
In a single line print n distinct integers from 1 to n β€” the required permutation. Numbers in a line should be separated by spaces. It is guaranteed that the answer exists.
standard output
PASSED
cd98d13ff190e6dc76cfed01637aefee
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class ZeroXORSubsetLess { static int mod = 1000000007; static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
58de4af2c8d30195aa6ffe0d05a14114
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
// upsolve with rainboy import java.io.*; import java.util.*; public class CF1101G { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] pp = new int[30]; int p = 0; StringTokeniz...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
255e2bb72cb0f62a905b0872695fdc98
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
0746a4cec88e963051adf0c008c26d76
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper p...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
bc5db33ff0208e6315042bad0eb8e76d
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class ZeroXORSubsetless { public static final long mod=1000000007; public static final int d=31; public static void main (String[] args) throws java.lang.Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWr...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
642340966e253ec8feb28d22d79943c4
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.util.Scanner; //https://codeforces.com/problemset/problem/1101/G public class ZeroXorSubsetless { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int xor = 0; for (int i = 0; i < n; i++) { ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
4496c3a84a5afdc881faa904b0242876
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class G { private static void swap(BitSet[] b, int i, int j){BitSet tmp=b[i]; b[i]=b[j]; b[j]=tmp;} private static int gauss_rank(BitSet[] bitSet, int N, int M) { int i,rank=0; for(int row=0,col=0;row<N&&col<M;++col) ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
6432f7fb28ecb6e2bc90b51f10e887e9
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
/* I don't understand the solution. I just saw this: https://codeforces.com/blog/entry/64483?#comment-484135 A bit of understanding: Rank of a matrix is the maximum number of linearly independent rows, which means that the max number of rows that can't be formed by some combination of other ro...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
80fde69757e72864d5b537b7d7e31eb5
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class G { private static void swap(BitSet[] b, int i, int j){BitSet tmp=b[i]; b[i]=b[j]; b[j]=tmp;} private static int gauss_rank(BitSet[] bitSet, int N, int M) { int i,rank=0; for(int row=0,col=0;row<N&&col<M;++col) ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
46caa2659e3a64c8255048ec9ed2e95e
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class G { private static void swap(BitSet[] b, int i, int j){BitSet tmp=b[i]; b[i]=b[j]; b[j]=tmp;} private static int gauss_rank(BitSet[] bitSet, int N, int M) { int i,rank=0; for(int row=0,col=0;row<N&&col<M;++col) ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
4a1c6c205892ea7b849d6849e235420c
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
e27373e0943a447b23666240c377229b
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
2303e64ccefa304c6e61c5758c5a2c84
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
9099331bdf1485214184ccd2e897c88e
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author beginner1010 */ public cla...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
4bb14fe46155c773015b2674afa84ddd
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
//package educational.round58; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class G { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
024b5b7a040257ca791803559f3b90e0
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int[] a=new int[n+1]; int[] b=new int[33]; for (int i=1;i<=n;++i) { a[i]=in.nextInt(); a[i]^=a[i-1]; } if (a[n]==0) { System.out.println(-1); return; } f...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
09ede9887ee73bb3e797d1c43c0a8235
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
f18ac39e451f5f3652407f2d611ac4c1
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.io.*; import java.util.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static Scanner sc = new Scanner(System.in); static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); long mod = 1000000000+7; long[] frac, inv; public stat...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
ed44e3d4806e42b469f447b2d711c076
train_001.jsonl
1547217300
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw...
256 megabytes
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { void solve() { int n=ni(); int a[]=new int[n+1]; for(int i=1;i<=n;i++){ a[i]=ni()^a[i-1]; } if(a[n]==0) { pw.println("-1"); return; }...
Java
["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"]
2 seconds
["2", "-1", "3"]
NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\...
Java 8
standard input
[ "math", "matrices" ]
0e0f30521f9f5eb5cff2549cd391da3c
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
2,300
Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.
standard output
PASSED
1bfd241753b40b0c25e63ab5d7431eef
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.util.*; import java.io.*; public class DwithPrecalc { FastScanner in; PrintWriter out; final long mod = 1000_000_000 + 7; public void solve() throws IOException { int n = in.nextInt(); int[] a = new int[n]; int count = 0; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); if (a[i] == 2...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
553bfccc5ed4ae9c7044b011476fdf26
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; 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.Locale; import java.util.Scanner; import java.util.StringTokenizer; impor...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
86fc5ef37a6958ff48413a5740c76ea9
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.List; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.ArrayList; ...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
b5d2fe09638c2286b2d30b0384ae746f
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class A { static final long mod = 1000000007; public static void main(String[] args) { MScanner sc = new MScanner(); PrintWriter out = new PrintWriter(System.out); int N = sc.nex...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
2b3a0795440d3ccbb48ec51578843cb7
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; import static java.util.Arrays.fill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStrea...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
75a883b01887378abccd58ac8b3d27ca
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.util.*; import java.io.*; public class PE { final static long mod = 1000000007; public static void main(String[] args) throws Exception { Parser in = new Parser(System.in); int n = in.nextInt(); int count2s = 0; for(int i = 0; i < n; i++) { int checker = in.nextInt(); if(checker == 2) { ...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
588a51d6b54f022552d14a0ad7d97ae8
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.util.HashSet; import java.io.InputStream; /**...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
b906fc1a4445869000d273c36130f493
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.*; import java.util.*; public class D { static void solve() throws IOException { int n = nextInt(); int one = 0, two = 0; for (int i = 0; i < n; i++) { int ok = nextInt(); if (ok == 1) { ++one; } if (ok > 1) { ++two; } } int answer = get(one, two); out.println(answer...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
abaf1482abbdc1be63452347969a28c3
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
//package abbyycup2013; import java.io.*; public class ProblemD12 { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); ProblemD12() throws IOException { // reader = new BufferedReader(new FileReader...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
65c29e8d73499f1d20cd26a16e6ced33
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.*; import java.util.*; public class cfABBYYCup3D { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static final int MOD = 1000000007; void solve() throws IOException { int n = nextInt(); String s = br.readLine(); int one = 0; int two = 0; for (int i = 0; i < s...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
f7b504e7d79b0517aa21d6cd525864ea
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class D { static long M = 1000L*1000*1000+7; static long A(long x, long y) { return (x+y)%M; } static long M(long x, long y) { return (x*y)%M; } static long fac(long n) { long ans = 1; for(int i=2; i<=n; i++) ans = M(ans, i); retur...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
d794599b62b9d2bff3d956f72e50d264
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Solution { BufferedReader in; PrintWriter out; ...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
1762219e1a99b17fd291aa81ebcb794c
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static final String input = "stdin"; static final String ouput = "stdout"; static final int MAXN = 1000010; static final int MOD = 1000000007; long[] F = new long[MAXN]; long[] I = new long[MAXN]; long ...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
57618af45a7b0c8d78cdaff365941090
train_001.jsonl
1371042000
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Set; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.HashSet; import java.io.InputStream; /** * Built using CHelper plug-in...
Java
["5\n1 2 2 1 2", "8\n1 2 2 1 2 1 1 2"]
3 seconds
["120", "16800"]
null
Java 7
standard input
[ "dp" ]
91e8dbe94273e255182aca0f94117bb9
The first line contains a single number n β€” the number of students in the line and the number of balls. The next line contains exactly n space-separated integers. Each number corresponds to a student in the line (the i-th number corresponds to the i-th from the left student in the line) and shows the number of throws h...
2,300
The output should contain a single integer β€” the number of variants of ball orders after the warm up exercise is complete. As the number can be rather large, print it modulo 1000000007 (109 + 7).
standard output
PASSED
bfda8944c919acd5aac78849f1ead897
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class B { public static void main(String[] args) { Scanner theIn=new Scanner(System.in); int n=theIn.nextInt(); int m=theIn.nextInt(); boolean t[][]=new boolean[n+1][m+1]; ArrayList<Integer> x=new ArrayList<Integer>(); ArrayList<Integer> y=new ...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
2d62c25e351efa7767372fa1ccf2a8e4
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class B168 { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; class Po...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
afdc9b81a6b4b082522d1a9ac6d9744c
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.*; import java.util.*; public class pr168B implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer str; public void solve() throws IOException { int n = nextInt(); int m = nextInt(); int[][] a = new int[n][m]; for (int i = 0; i < n; i++) { String s = nextToken(); fo...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
94226350ea14310c35a176a86c86d25f
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.*; import java.io.*; public class B { private static boolean[][][] d_x; private static boolean[][][] d_y; public static void main(String[] args) throws IOException { Scanner ins = new Scanner(System.in);//new FileInputStream(new File("./input.txt"))); PrintStream outs = System.out; int n=i...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
9f7d8bd3e9d8285453ce0345296370c9
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outpu...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
70bc3558301a2234dbd0ed31a0bec0ca
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.PrintStream; import java.util.*; public class Main { public static void main(String arg[])throws Exception{ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); sc.nextLine(); boolean grid[][]=new boolean[n][m]; for (int i=0;i<n;i...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
8c1790c22c599eed343f80f1a5b13352
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.*; public class Main { int [] vx = {0,1,0,-1}; int [] vy = {1,0,-1,0}; char [][] data; class C{ int x, y, dir, count; public C(int x, int y, int dir, int count) { this.x = x; this.y = y; this.dir = dir; this.coun...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
73b98c65dddad0f6f7dd11b1d11c1664
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import static java.lang.Math.min; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Solution { public s...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
72e5aa9005d5ea83cd737314f6521c6c
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.*; import java.io.*; public class convex { static int n, m; static char grid[][]; public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); grid = new char[m][n]; for (int i = 0; i < n; i++) { String...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
4e200060c3c6815e53f4334f9bd02884
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.*; import java.io.*; public class a { static long mod = 1000000007; static boolean[][] blacks; public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(new PrintStream(System.out)); //Scanner input = new Scanner(new File("input.txt")...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
5f644339e0990c8dba8a3974331cd8a1
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.StringTokenizer; public class B { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanner(){ br=new BufferedRead...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
f82a474a4a43abb45543ce5de55b75a7
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CF169B { private static int contains (int[] a, int[] b){ int result = 1; int length = a.length; for (int i=0;i<length;i++){ if (a[i]<b[i]) return 0; } return result; } private static int isConti...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
bc830c9ca95e35153d4222d72aa15060
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CF169B { private static int contains (int[] a, int[] b){ int result = 1; int length = a.length; for (int i=0;i<length;i++){ if (a[i]<b[i]) return 0; } return result; } private static int isConti...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
8d6fae29e3633e715b821aaa146e0e36
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Arrays; import java.util.LinkedList; import java.util.StringTokenizer; public class CodeD { static class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringToken...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
4dabb7e9ff521a9ff708197b08589367
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.ArrayList; import java.util.LinkedList; import java.util.Scanner; public class CodeforcesRound168B { direction2d[] dir2d = { new direction2d(1, 0), new direction2d(0, 1), new direction2d(-1, 0), new direction2d(0, -1) }; int n, m; boolean[][] data; cl...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
2adfc09d347d4181321f6a2930c920ce
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.*; import java.util.*; public class BR168 { BufferedReader in; PrintWriter out; StringTokenizer st; private char[][] a; class Point{ int i, j; Point(int i, int j){ this.i = i; this.j = j; } } boolean notHaveWOnLine(int i, int from, int to){ for (int j = from; j <= to; j++) if ...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
2ae3498ef149da5b63d07e752c9da33f
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.*; import java.util.*; import java.util.StringTokenizer; import java.math.BigInteger; public class SolutionB { BufferedReader in; StringTokenizer str; PrintWriter out; String SK; long ff[]; String next() throws IOException { while ((str == null) || (!str.hasMoreTokens())) { ...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
6d75db0351fe4897f3842ed7fbc8b4f4
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arr...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
35290a051d20a7c23ef791dff69f01fe
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static Input in; static Output out; static final boolean OJ = true; public static void main(String[] args) throws IOException { in = new Input(OJ ? System.in : new FileInputStream("in.txt")); out = new Ou...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
345bcf7dbc1cd80403202c9dde8831bc
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int[][] array = new int[n][m]; int count = 0; boolean make = true; for ...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
7f898895f654dfdeb6e51259071ada34
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Task2 { private static boolean[][] table; private static State[] rowState, colState; static BufferedReader r = new BufferedReader(new I...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
340d33ac78d1bdcfb6020e7ddaae43b2
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.StringTokenizer; import java.util.TreeMap; /* * To change thi...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
4e59eac68ee36aa623ca453989197996
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main{ static char ma[][]; static int row[][]; static int col[][]; public static void main(String[] args) throws Throwable { Buff...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
3b1ec197e55451a47b89e894006ad3a5
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.util.*; public class ConvexShape { static int n; static int m; static String[] map; static boolean[][] isVisited; public static void main(String[] args) { Scanner sc=new Scanner(System.in); n=sc.nextInt(); m=sc.nextInt(); map=new String[n]; for (int i = 0; i < n; i++) { map[i]=sc.ne...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
f7823358cb7e522a8ceaa035264b6338
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.*; public class ConvexShape { /** * @param args */ public static void main(String[] args) { try{ //BufferedReader br=new BufferedReader(new FileReader("C:/Users/MINTOO/Desktop/Programs/Java/ConvexShape.txt")); BufferedReader br=new BufferedReader(new In...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
8c66c0023c1fb7d7890c5a54dc6ce51b
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner s = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); ...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output
PASSED
e3449c7bd005e65e8a9274ef832e7c66
train_001.jsonl
1361374200
Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa...
256 megabytes
import java.awt.Point; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Enumeration; import java.util.Iterator; import...
Java
["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW"]
2 seconds
["NO", "YES"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
3631eba1b28fae473cf438bc2f0552b7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 50) β€” the size of the grid. Each of the next n lines contains m characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid. It's guaranteed that the grid has at least one black cell.
1,700
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
standard output