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
079592a24210bd801e684b36134a858b
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.*; import java.util.ArrayDeque; import java.util.Queue; import java.util.StringTokenizer; public class E_PolygonCannons { private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new Ou...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
6469b52d360660e723c9c468f4f5c87f
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Scanner in = new Main().new Scanner(inputStream); Main s...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
688fc4763671b2a2564d9a8324224f6b
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { // write your code here Scanner in = new Scanner(System.in); int t=in.nextInt(); String []ansarr=new String[t]; for(int i=0;i<t;i++) { int n=in.nextInt(); ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
3cdabf8bb2101999388b468d9a45136b
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Comparator; import java.util.Random; import java.util.StringTokenizer; public class Main { static ArrayList<Integer>[] gr; static boolean[] was;...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
fe0c71126fc9d83962a0e17602113926
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int[][] ar=new int[n][n]; for(int i=0;i<n;i++){ ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
bed624fe789e166af648d49790d3400b
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.lang.Math; public class Polygon{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int u = 0; u < t; u++){ int n = sc.nextInt(); boolean[][] grid = new boolean[n][n]; boolean flag = true; for(int i = 0; i ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
80c51aeef4d53ecf3274aa9fbab5f527
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf182 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
67031e07b59a1520cffb2760881fb7b4
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.InputStreamReader; import java.io.FileOutputStream; import java.util.StringTokenizer; public class Polygon{ static BufferedWriter out; static FastReader sc; public static void m...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
14401fcbcfb29370848a17b5853f1e95
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException { int test = GetInput.getInt(); while (test-...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
b9e2653f8e70771c22726acf97c990c0
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.*; import java.util.*; public class E { static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static void solve() { int n = sc.nextInt(); int[][] matrix = new int[n][n]; for (int i = 0; i < n; i ++){ char[] s = s...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
4af78f2fc680738047b4cb4c1b978648
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
/* package codechef; // don't place package name! */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class HelloWorld{ public static void main(String []args){ Scanner input = new Scanner(System.i...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
a18f22fac413071e99de9b71d309f9b7
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.Scanner; public class CF1360E { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = Integer.parseInt(sc.nextLine()); testcase: while (t-- > 0) { int n = Integer.parseInt(sc.nextLine()); boolean [][]trainingReport...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
ac69bb617644a6218ab1486579519b6c
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { int t = sc.nextInt(); while(t-- > 0) solve(); out.close(); } private static void solve() { int n = sc.nextInt(); char[][] grid = new char[n][n]; for(int i = 0; i < n; i+...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
33f0194e89c24e466de146c04a9a07b9
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.Scanner; public class Polygon { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int i=0;i<t;i++) { int n=s.nextInt(); String[] box=new String[n]; for(int j=0;j<n;j++) { box[j]=s.next(); } ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
a3b30b0e5abfb42c31846c8e58acddae
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Learning { public static void main(String[] args) throws Exception { FastInput in = new FastInput(); StringBuilder st = new StringBuilder(); int t = i...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
5879fc7b3e8f1d93556a628c5e1b86fa
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.io.*; public class cf { public static void main(String[] args) { FastReader in = new FastReader(); int t = in.nextInt(); while(t-- >0) { int n = in.nextInt(); boolean flag = false; int[][] arr = new int[n][n]; ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
7c2bcf7987b4b42149dc199d2c02c4d3
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.io.*; public class cf { static boolean multiple_testcases = true; static FastReader in = new FastReader(); static void solve() { int n = in.nextInt(); boolean flag = false; int[][] arr = new int[n][n]; for(int i=0;i<n;++i) { ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
cf3736617d20b44a727332f87c38bcd6
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class j8 { public static void main (String[] args) throws java.lang.Exception { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t-->0){ boolean flag=true; int n=in.nextInt(); String s[]=new String[n]; for(int i=0;i<n;i++){...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
6b9598807b938b8881cc669cf1b5bda5
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
//package codeforces; import java.util.Scanner; public class Polygon { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); sc.nextLine(); int mat[][] = new int[n][n]; for(int i = 0;i<n;i++) { String ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
9131bbf79ef5fd1c2a998870460b3903
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
/* package codechef; // don't place package name! */ import javax.swing.text.html.parser.Entity; import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Solution { // Complete the maximumSum function below. public static class...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
3c524cd90b439061adcb8e7cd32b63b2
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; public class Polygons { public static int check(int[][][] arr,int n) { for(int j=0;j<n;j++) { for(int k=0;k<n;k++) { if(arr[j][k][0]==1 && j!=n-1 && k!=n-1) { if(arr[j+1][k][0]!=1 && arr[j][k+1][0]!=1) { return -1; } } } } return 1; } public stat...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
d16d62ba34414fb7490138a33ec4d15d
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Polygon { public static void main(String [] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-->0) { int n = sc.nextInt(); Str...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
d2b0edcd3fc3b0d457d5c5b7390ce75d
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class P { public static void ma...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
d4fc78bd4ad2eb05b662a2444b867276
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
256 megabytes
import java.util.*; import java.io.*; public class Polygon { // https://codeforces.com/contest/1360/problem/E public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new BufferedReader(n...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
04a9e4df18faba44e8c3236f2fdb6075
train_003.jsonl
1590327300
Polygon is not only the best platform for developing problems but also a square matrix with side $$$n$$$, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cannon above each cell in the first row and a cannon to the left of each cell in the first column. Thus, exact...
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 dauom */ public class Main { ...
Java
["5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111"]
2 seconds
["YES\nNO\nYES\nYES\nNO"]
NoteThe first test case was explained in the statement.The answer to the second test case is NO, since a 1 in a cell ($$$1, 1$$$) flying out of any cannon would continue its flight further.
Java 11
standard input
[ "dp", "implementation", "graphs", "shortest paths" ]
eea15ff7e939bfcc7002cacbc8a1a3a5
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 50$$$) — the size of the polygon. This is followed by $$$n$$$ lines of length $$$n$$$, consisting of 0 and 1 — t...
1,300
For each test case print: YES if there is a sequence of shots leading to a given matrix; NO if such a sequence does not exist. The letters in the words YES and NO can be printed in any case.
standard output
PASSED
1abf07697051d31418aff283e516f8c0
train_003.jsonl
1381838400
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament...
256 megabytes
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import java.util.Tr...
Java
["4 3\n1 2 1\n1 3 3\n1 4 4", "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1"]
3 seconds
["3 1 4 0", "0 8 4 6 4 8 6 1"]
NoteConsider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.
Java 7
standard input
[ "data structures" ]
a608eda195166231d14fbeae9c8b31fa
The first line contains two integers n, m (2 ≤ n ≤ 3·105; 1 ≤ m ≤ 3·105) — the number of knights and the number of fights. Each of the following m lines contains three integers li, ri, xi (1 ≤ li &lt; ri ≤ n; li ≤ xi ≤ ri) — the description of the i-th fight. It is guaranteed that the input is correct and matches the p...
1,500
Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.
standard output
PASSED
0eee3dc8094600252af54e2b22a3bc35
train_003.jsonl
1381838400
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament...
256 megabytes
import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StreamCorruptedException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.LinkedList; import java.util.PriorityQueue; import java...
Java
["4 3\n1 2 1\n1 3 3\n1 4 4", "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1"]
3 seconds
["3 1 4 0", "0 8 4 6 4 8 6 1"]
NoteConsider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.
Java 7
standard input
[ "data structures" ]
a608eda195166231d14fbeae9c8b31fa
The first line contains two integers n, m (2 ≤ n ≤ 3·105; 1 ≤ m ≤ 3·105) — the number of knights and the number of fights. Each of the following m lines contains three integers li, ri, xi (1 ≤ li &lt; ri ≤ n; li ≤ xi ≤ ri) — the description of the i-th fight. It is guaranteed that the input is correct and matches the p...
1,500
Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.
standard output
PASSED
b6e78b842291170684194009bba146bf
train_003.jsonl
1381838400
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament...
256 megabytes
import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StreamCorruptedException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.LinkedList; import java.util.PriorityQueue; import java...
Java
["4 3\n1 2 1\n1 3 3\n1 4 4", "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1"]
3 seconds
["3 1 4 0", "0 8 4 6 4 8 6 1"]
NoteConsider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.
Java 7
standard input
[ "data structures" ]
a608eda195166231d14fbeae9c8b31fa
The first line contains two integers n, m (2 ≤ n ≤ 3·105; 1 ≤ m ≤ 3·105) — the number of knights and the number of fights. Each of the following m lines contains three integers li, ri, xi (1 ≤ li &lt; ri ≤ n; li ≤ xi ≤ ri) — the description of the i-th fight. It is guaranteed that the input is correct and matches the p...
1,500
Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.
standard output
PASSED
9ef6ced09f6269e8edf8231c979787be
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; public class Codechef { static long fac[] = new long[1000001]; static void perm() { fac[0]=1; for (int x=1;x<=1000000;x++) fac[x]=fac[x-1]*x; } static long power(long x, long y, long p) ...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
70dbe2528f582311cb52e65822aea784
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Solution { public static void main (String[] args) throws java.lang.Exception { Scanner sc= new Scanner(System.in); in...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
416b41dbcd6fd44c4efb52645a20053a
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class New_year_garland { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0) { int[] arr = new int[3]; for(int i=0;i<3;i++) { arr[i] = s.nextInt(); } Arrays.sort(arr); if(arr[...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
573ea37cc7b4d803f3c8e1dba8f38e32
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf232 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceChar...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
b58310c056e105c701a3ffeb75f7aa01
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = toInt(sc.nextLine()); for (int i = 0; i < t ; i++) { int r = sc.nextInt(), g = sc.nextInt(), b = sc.nextInt(); ...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
df2f47e50d7126012b08322f95b50e89
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class c1 { public static FScanner scan; public static PrintWriter out; public static void main(String[] args) { scan=new FScanner(); out=new PrintWriter(new BufferedOutputStream(System.out)); // int t=1; int t=...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
e401a3e5a28f628d7061a16439eef6e6
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.util.*; public class Main { public static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int r = scanner.nextInt(); int g = scanner.nextInt(); int b = s...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
2ace52adf79e596abf408bae8410d202
train_003.jsonl
1577457600
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them an...
256 megabytes
import java.util.*; import static java.util.Comparator.*; public class A { public static void main(String args[]) { int cases; Scanner lec = new Scanner(System.in); cases = lec.nextInt(); List lst; for (int i = 0; i < cases; ++i) { double r, g, b; r ...
Java
["3\n3 3 3\n1 10 2\n2 1 1"]
1 second
["Yes\nNo\nYes"]
NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.
Java 8
standard input
[ "math" ]
34aa41871ee50f06e8acbd5eee94b493
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.
900
Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
standard output
PASSED
7e4f196cbe3e9c0d9c8c2accfd7b8f23
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
//package com.company; import java.util.HashMap; import java.util.Scanner; public class CF_1045_I { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s[]=new String[n]; for(int i=0;i<n;++i) s[i]=sc.next(); Has...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
a4c70af2bb50c71437d5099dbd82d858
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void findPalPairs(ArrayList<String>[] hash){ OutputStream output = System.out; PrintWriter out = new PrintWriter(output); long ans = 0; if(hash[0].size() > 1){ long n =...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
e401eea14ff30180be12d8a632a4d727
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void findPalPairs(ArrayList<String>[] hash){ OutputStream output = System.out; PrintWriter out = new PrintWriter(output); long ans = 0; if(hash[0].size() > 1){ l...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
fd8f59b36de5800e90bbe5e594ab6ff1
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); HashMap<String, Integer> map = new HashMap<>(); Str...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
2b2b767c99754b5ee218858bc7cb643e
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String []args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
fd977f5adc8eb73c9a126aa55046d379
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class I { stati...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
49f2b953de29856980b7d67e271a747b
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int N; static String[] S; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); S = new String[N]; for (int i = 0; i < N; i++) { S[i] = sc.next();...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
cd935ee079d35bf4affea5a06edd7710
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class SOlution { public static void main(String ag[]) { Scanner sc=new Scanner(System.in); int i,j,k; int N=sc.nextInt(); String A[]=new String[N]; for(i=0;i<N;i++) A[i]=sc.next(); HashMap<Long,Long> hm...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
cf648514a415cdbd2a7ea414cea38ae4
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.System.out; public class Codeforces { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
dcc7a37841c4b256f0dd844e952581f5
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.util.regex.*; public class Main4 { public static void main(String[] args)throws Exception { Reader reader = new Reader(); reader.readLine(); int n = reader.readInt(0); HashMap<Integer,Integer> freq = new HashMap<>(); long ans =...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
cc7c4f76eff011a46f2d93c6cf4acd5c
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { static int[][] count; static long[] result; static long[] sameCount; static long des; public static void main(String[] args) throws IOException { ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
4e8cdad86cf981c80be9a465bbb093da
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Code { public static String odds(String s) { int[] arr = new int[28]; for(int i=0;i<s.length();i++) { a...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
71361d69d91274ec33fc4046c0664b0a
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; public class PalindromePairs { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); HashMap<Integer,Integer> f=new HashMap<>(); int[] masks=new int[n]; for(int i=0;i<n;i++) { String s=scan.next(); int mask=mask(s); f.put(mask,f.getO...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
64bcbc9155abf0229c35c3c52d6d5cbe
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; public void solve() throws IOException { int n = readInt(); ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
14e84f6e46fc833d507c4e8e0b8e7a05
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.HashMap; import java.io.*; /** * * @author arvin */ public class pallindrome_pairs { public static void...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
2c1afbdcdffe89f8a465b05554ec3f7e
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class icpc { static long count = 0L; public static void main(String[] args) throws IOException { // Reader in = new Reader(); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.par...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
7f62af8927842ddd59108d3dd528a8a3
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.util.HashMap; import java.util.Scanner; import static java.lang.System.*; public class Main { private int[] num; private HashMap<Integer, Integer> hashtable; private int gcd(int x, int y) { if (x == 0) return y; ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
b66ccb83c0a3f244b524f5c7a09a9141
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
//package bubble11; 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 I { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); int...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
f00bad21dc29b989a5f94e0405c88b37
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class i { public static void main(String[] args) { new i(); } i() { FastScanner fs = new FastScanner(); int n = fs.nextInt(); String[] a = new String[n]; for(int i = 0; i < n; i++) { a[i] = fs.next(); } HashMap<Integer, Integer> map = new HashMap<>(); ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
5eb1eef2aaca22d675be8bc5241c50b0
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* */ import java.util.*; import java.io.*; public class x1045I { public sta...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
446cf0620698a6d8b8b660b2d40e8ba6
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; /** * Created by Katushka on 05.02.2020. */ public class PalindromPairs { public static void main(String[] args) throws FileNotFoundException { InputReader in = new InputReader(System.in); PrintWri...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
c4446bf9bcff762a935af5c70896fbd1
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
aa7f1b6525f2af891b124b5364ead8b7
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class sonuu{ public static void main(String[] args){ FastReader sc=new FastReader (); PrintWriter out = new PrintWriter(System.out); ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
f761d0209be1a05271212a94b8da34e2
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class I_PalindromePairs { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
6486d0b097a5cf388a78ddeaaa9582fa
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Map; import java.io.Writer; import java.util.HashMap; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solut...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
c4975640835891f3a8caf9c5f2409db6
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gcd(long a,long b) { return b==0?a:gcd(b,a%b);...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
a6886cc793585aff17051cf91b09e550
train_003.jsonl
1537612500
After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she...
256 megabytes
import java.io.*; import java.util.*; public class Main2 { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static String ns() { while(st==null||(!st.hasMoreTokens())) { try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { // ...
Java
["3\naa\nbb\ncd", "6\naab\nabcac\ndffe\ned\naa\naade"]
2 seconds
["1", "6"]
NoteThe first example: aa $$$+$$$ bb $$$\to$$$ abba. The second example: aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$...
Java 8
standard input
[ "hashing", "strings" ]
2475df43379ffd450fa661927ae3b734
The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. The total number of characters in the input array will...
1,600
Output one number, representing how many palindrome pairs there are in the array.
standard output
PASSED
e66fb231594b138b0d47cede6a1b7f75
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; /**...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
f2417deae38e51805bdeadc581b95b85
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { private IO io; private int ioMode = -1; private String problemName = ""; private final String mjArgument = "master_j"; public static void main(String programArguments[]) throws IOException{ if(program...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
119b3a8cc6234a599381348fcdcedaf7
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.*; public class AncientProphesy { static final int DATE_LEN = 10; // dd-mm-yyyy static final int[] DAYS_PER_MONTH = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static boolean isValid(String date) { String[] parts = date.split("-"); if (parts.length != 3) return false; if (parts[0].l...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
a7dec69ba5da674058ab421c5446f139
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.Map; import java.io.InputStreamReader; import java.io.IOException; import java.util.HashMap; import java.util.Set; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in *...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
f5abc9b9d21ad94667be2486aba01a0d
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.*; public class B{ static final int [] DAYS = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; public static void main(String [] args){ Scanner s = new Scanner(System.in); final String line = s.nextLine(); String res = ""; int count = 0; for (int y = 2013; y <= 2015; ++y){ for (int m = ...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
1a6dafb17993eaedd7d3d8800fcdaf84
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.Scanner; public class ElephantChess { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int freq[][][] = new int[31][12][3]; int monthLen[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String stroka = sc.nextLine(); int max...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
826565f8eef161a1f92f902093b57a98
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { Map<Integer, Integer> mp = new HashMap<Integer, Integer>(); int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void gao(char[] s, int base) { for (int i = 0; i < 10; ++i) { if (base +...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
7a8ef0574d70364f15b44b250d38d003
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class P260B { private final int [] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; private boolean isDigit(char c) { return (c >= '0' && c <= '9'); } private boolean isMinus(char c) { return (c == '-'); }...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
211fae8999dd8593857c0c8611ef6dc1
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Hashtable; import java.util.ArrayList; import java.util.Set; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; imp...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
c7c33ed473cf6d36d7d9a4879a0c37f4
train_003.jsonl
1356622500
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that ...
256 megabytes
import java.util.Map; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.FileReader; import java.io.BufferedWriter; import java.util.HashMap; import java.io.BufferedReader; import java.io.OutputStream; import java.io.Prin...
Java
["777-444---21-12-2013-12-2013-12-2013---444-777"]
1 second
["13-12-2013"]
null
Java 7
standard input
[ "implementation", "brute force", "strings" ]
dd7fd84f7915ad57b0e21f416e2a3ea0
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
1,600
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
standard output
PASSED
033d0a6cfbe562124e94ce785a305fa0
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.TreeSe...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
ac86bd12159695a157a83614a70a2e75
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.util.*; public class CF607D { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int t = Integer.par...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
8b8102c1025f783d518070b3a8bb69e2
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int cases = Integer.parseInt(in.readLine()); outer: for (int test = 0; test < cases; test++) { ...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
8c159a2769091c257bf2e50d24ebd49f
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unused") public class Main { FastScanner in; PrintWriter out; int MOD = (int)1e9+7; long ceil(long a, long b){return (a + b - 1) / b;} long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);} long lcm(long a, long b){return a / gcd(a,...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
8a7a61358ea071e7e91eb3412298b40f
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
// package com.company; import java.util.*; import java.lang.*; import java.io.*; //****Use Integer Wrapper Class for Arrays.sort()**** public class BD4 { public static void main(String[] Args){ FastReader scan=new FastReader(); int t=scan.nextInt(); StringBuilder print=new StringBuilder(); ...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
3ea9291be74d3de2a4b38ba97efbdef9
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Beingawesomeism { public static void main(String[] args) throws IOException { OutputStream outputStream = System.out; Reader in = new Reader(); Prin...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
5dcda8796c212ebf2a4dad3a7ed0a1f6
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; // static long oo = (long)1e15; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
a5ab19a9141cf0a9a8dc93b2e2fdf0ba
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.util.*; import java.io.*; import java.io.FileWriter; import java.math.BigInteger; import java.math.BigDecimal; // Solution public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; final int[][] dirs8 = {{0,1}, {0,-1}, {-1,0}, {1,0}, ...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
6f9f2da60dc435130c56ccfe5471bc44
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
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
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
c43f2d45814ec8cc5dbccb7cd77656e0
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; // written by luchy0120 public class Main { public static void main(String[] args) throws Exception { new Main().run(); } int color[],dfn[],low[],stack[],cnt[]; boolean vis[]; boolean iscut[]; int deep,top,n,m,sum,an...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
4c4f57ed6c5898a3065bb0d291947326
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; // written by luchy0120 public class Main { public static void main(String[] args) throws Exception { new Main().run(); } int color[],dfn[],low[],stack[],cnt[]; boolean vis[]; boolean iscut[]; int deep,top,n,m,sum,an...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
b5c95303155c513d3cdabdc2521f167c
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class beingawesomeism { public static void main(String[] args) throws IOException { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int cases = Integer.parseInt(scan.nextToken())...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
8404b1fe543eb65e49028cee3243ae09
train_003.jsonl
1576386300
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $$$r \times c$$$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Be...
256 megabytes
import java.util.*; import java.io.*; public class P1281D { private static void solve() { int t = nextInt(); while (t-- != 0) { int n = nextInt(); int m = nextInt(); char[][] g = new char[n][m]; for (int i = 0; i < n; i++) { g[i] = next().toCharArray(); } int...
Java
["4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP"]
2 seconds
["2\n1\nMORTAL\n4"]
NoteIn the first test case, it can be done in two usages, as follows:Usage 1: Usage 2: In the second test case, it can be done with just one usage of the power. In the third test case, it is impossible to convert everyone to Beingawesomeism, so the answer is "MORTAL".
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
da18ca9f125d1524e7c0a2637b1fa3df
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) denoting the number of test cases. The first line of each test case contains two space-separated integers $$$r$$$ and $$$c$$$ denoting the dimensions of the grid ($$$1 \le r, c \le 60$$$). The next $$$r$$$ lines each contains $$$c...
1,800
For each test case, output a single line containing the minimum number of usages of your power needed to convert everyone to Beingawesomeism, or the string "MORTAL" (without quotes) if it is impossible to do so.
standard output
PASSED
78ea234fca1f00700a8ee7bc95b29f03
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
///package CodeForce; import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class EduRound20F { static int[] A; static int[] S; static long[] sum; public static int mod=1000000007; static int[][] dp; static boolean[][] isPalin; static int ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
def29303b092dbc990951ec484cb7919
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new In...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
d6b7fd7363c6fdbf67773dcd558c19a4
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class _0803_F_CoprimeSubsequences { public static void main(String[] args) throws IOException { int N = readInt(), maxN = 100000, MOD = 1000000007; boolean seive[] = new boolean[maxN+1]; seive[1] = seive[0] = true; ArrayList<Integer> prime = new ArrayList<>(); f...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
f60037f7036315c6479c2de301fb9d07
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java....
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
acd72bd5aeafa87d80fc67c79fe18637
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class f { static long MOD = (long)1e9+7; static int MAX = 100001; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] subs = new long[MAX]; Arrays.fill(subs, 1); for(int i=0;i<n;i++) { int v...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e65d85c2c95fe3a8077f5def010e76fd
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
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.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
57569a94c7f2920dce3d20299325df53
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer buffer; static int MAX = 100100; static long MOD = 1_000_000_007...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
dff266eeccf3ca8666745ce411ced1eb
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer buffer; static int MAX = 100100; static long MOD = 1_000_000_007...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
536eed982a7b63552402fb744df599c0
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; impo...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
bc6a844e3a3213454a27c50d9364d942
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class A { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; static long mul(long a, long b) { a %= mod; b %= mod; long c = a * b; return c % mod; } public static void main(String[] args) ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
67a7f8b195f73f712eda7f3b25062e6b
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/** * author: derrick20 * created: 11/4/20 1:42 PM */ import java.io.*; import java.util.*; import static java.lang.Math.*; public class CoprimeMobius { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); in...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
a04e7aea64ef00940e7d24bab406125b
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/** * author: derrick20 * created: 11/4/20 2:31 PM */ import java.io.*; import java.util.*; import static java.lang.Math.*; public class CoprimeMobiusSimple { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e32c52c2c7479ca5aa0b34be62aceb98
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/** * author: derrick20 * created: 11/4/20 2:31 PM */ import java.io.*; import java.util.*; import static java.lang.Math.*; public class CoprimeMobiusSimple { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
5099f40915fb485e4ce177678634c38e
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
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
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≤ n ≤ 100000). The second line contains n integer numbers a1, a2... an (1 ≤ ai ≤ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output