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
0c2a8c87b36d4c420fc29e7266c87b3b
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
import java.util.*; import java.io.*; public class EdD { static long[] mods = {1000000007, 998244353, 1000000009}; static long mod = mods[0]; public static MyScanner sc; public static PrintWriter out; static ArrayList<ArrayList<Integer>> tree; static int[] depth; static int[] parent; public static v...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
d459fce5838d8921d4ea7aa0d557d270
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7; static List<int[]>[] g; static boolean[] b; static List<Integer> cycle; static int[] mark,bap; static void dfs(int u,int p) throws IOException{ if(m...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
89da62cbd984c02840d50d7a95d9e424
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7; static List<int[]>[] g; static int[] in,low; static boolean[] b; static int timer=0; static int tmp=0; static void dfs(int u,int p){ in[u]=low[u]=ti...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
fb6a20409914339ea44704b14aaf04d9
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7; static List<int[]>[] g; static boolean[] b; static List<Integer> cycle; static int[] mark,bap; static void dfs(int u,int p) throws IOException{ if(m...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
9447dcc2cd76dd51d3e08c568f62bf7d
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7; static List<int[]>[] g; static boolean[] b; static List<Integer> cycle; static int[] mark,bap; static void dfs(int u,int p) throws IOException{ //if...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
39c1519f8a190ece9a368dfa4e10a7fe
train_000.jsonl
1606228500
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng...
256 megabytes
//package codeforces.round686div3; import java.io.*; import java.util.*; public class E { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); solve(in.nextInt()); //solve(1); ...
Java
["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"]
2 seconds
["6\n11\n18"]
NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$.
Java 8
standard input
[ "combinatorics", "dfs and similar", "trees", "graphs" ]
1277cf54097813377bf37be445c06e7e
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$...
null
For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths).
standard output
PASSED
ec507f5e14c27a6e4d24995f4cb3e772
train_000.jsonl
1316098800
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as follows: Each pipe segment has two ends, illustrated by the arro...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.*; import java.math.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out...
Java
["2 2\n13\n..", "3 1\n1\n4\n.", "2 2\n3.\n.1"]
3 seconds
["2", "0", "1"]
NoteFor the first example, the initial configuration of the grid is as follows. The only two possible final non-leaking pipe configurations are as follows: For the second example, the initial grid is already leaking, so there will be no final grid that is non-leaking.For the final example, there's only one possibl...
Java 8
standard input
[]
07cbcf6e1f1e7f1a6ec45241cf9ac2a9
The first line will contain two single-space separated integers n and m (1 ≤ n, m, n·m ≤ 5·105) — the number of rows and columns respectively. Then n lines follow, each contains exactly m characters — the description of the grid. Each character describes a cell and is either one of these: "1" - "4" — a pipe segment ...
2,200
Print a single integer denoting the number of possible final non-leaking pipe systems modulo 1000003 (106 + 3). If there are no such configurations, print 0.
standard output
PASSED
bde1b80807898c3bcf60ffcb0736c2e7
train_000.jsonl
1316098800
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as follows: Each pipe segment has two ends, illustrated by the arro...
256 megabytes
import java.util.*; public class cf115c { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); char[][] v = new char[n][]; for(int i=0; i<n; i++) v[i] = in.next().trim().toCharArray(); int ret = 1; int mod = (int)1e6+3; boolean[] ...
Java
["2 2\n13\n..", "3 1\n1\n4\n.", "2 2\n3.\n.1"]
3 seconds
["2", "0", "1"]
NoteFor the first example, the initial configuration of the grid is as follows. The only two possible final non-leaking pipe configurations are as follows: For the second example, the initial grid is already leaking, so there will be no final grid that is non-leaking.For the final example, there's only one possibl...
Java 6
standard input
[]
07cbcf6e1f1e7f1a6ec45241cf9ac2a9
The first line will contain two single-space separated integers n and m (1 ≤ n, m, n·m ≤ 5·105) — the number of rows and columns respectively. Then n lines follow, each contains exactly m characters — the description of the grid. Each character describes a cell and is either one of these: "1" - "4" — a pipe segment ...
2,200
Print a single integer denoting the number of possible final non-leaking pipe systems modulo 1000003 (106 + 3). If there are no such configurations, print 0.
standard output
PASSED
9f4d03d90012c825b7bd010793006682
train_000.jsonl
1316098800
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as follows: Each pipe segment has two ends, illustrated by the arro...
256 megabytes
import java.util.*; public class A { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = 3; int ans = 1; boolean f = true; int m = in.nextInt(); ...
Java
["2 2\n13\n..", "3 1\n1\n4\n.", "2 2\n3.\n.1"]
3 seconds
["2", "0", "1"]
NoteFor the first example, the initial configuration of the grid is as follows. The only two possible final non-leaking pipe configurations are as follows: For the second example, the initial grid is already leaking, so there will be no final grid that is non-leaking.For the final example, there's only one possibl...
Java 6
standard input
[]
07cbcf6e1f1e7f1a6ec45241cf9ac2a9
The first line will contain two single-space separated integers n and m (1 ≤ n, m, n·m ≤ 5·105) — the number of rows and columns respectively. Then n lines follow, each contains exactly m characters — the description of the grid. Each character describes a cell and is either one of these: "1" - "4" — a pipe segment ...
2,200
Print a single integer denoting the number of possible final non-leaking pipe systems modulo 1000003 (106 + 3). If there are no such configurations, print 0.
standard output
PASSED
070100667b502172c68cd87ed2c1113a
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
//package proje; //import java.io.BufferedReader; //import java.io.BufferedWriter; //import java.io.InputStreamReader; import java.io.*; import java.util.*; public class jk { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String f = sc.next(); OutputStream out...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
4b1186947ee9cd629cae207dbb5d849d
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { public static void main(St...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
d7f33db495430e890ad9835fe10e7164
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
/** * ******* Created on 12/11/19 1:44 PM******* */ import java.io.*; import java.util.*; public class C600 implements Runnable { private static final int MAX = (int) 1e5 + 10; private static final int MOD = (int) 1e9 + 7; private void solve() throws IOException { int t = 1; while (t-...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
856ee7d15346def50ac81c4a376938fc
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.Scanner; //import java.lang.StringBuilder; public class Main { public static void main (String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); int a = str.length(); char[] c = str.toCharArray(); int[] d = new int[26]; for ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
c712b12d73de1a402a64c8b639e1c5d2
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class EDU2C { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); String...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
f3f1b65eb0bd1103c9781de1a7e6c49d
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.*; public class a{ public static void main(String[] args) { Scanner in=new Scanner(System.in); String s=in.next(); char[] ar=s.toCharArray(); int[] freq=new int[26]; for(int i=0;i<ar.length;i++) freq[ar[i]-'a']++; TreeMap<Character,Integer> map=new ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
279d76183656e6c9a6ecec1e27690eb7
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; /** * * @author Mohammad Hadi */ public class ED2C { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.nextLine(); int[] mark = new int['z' - 'a' + 1]; for (int i = 0; i < s.length()...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
2926a16b0dd2850424d03d37dc0dd370
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.InputMismatchException; public class Solution123 implements Runnable { static final int...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
0ab5b77d3aee4b9a48c99d923970d09a
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.IOException; public class CF600C { public static void main(String[] args) throws IOException { int[] cnt = new int[26]; int ch; int len = 0; do { ch = System.in.read(); if (ch >= 'a' && ch <= 'z') { cnt[ch - 'a']++; ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
a1af1aec835552668871ab4d5523a61e
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
//package com.himanshu.practice.aug14.educationalround; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; /** * Created by himanshubhardwaj on 13/08/18. */ public class MakePalindrome { static char[] string; stat...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
f6683f089f52a67dc66e90f3636cf897
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C600C { public static void main(String[] args) throws Exception { new C600C().run(); out.close(); } ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
179522f88d8f49d3cbce4c4f2aeb1d6e
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.*; import java.util.*; /* * Heart beats fast * Colors and promises * How to be brave * How can I love when I am afraid to fall... */ //read the question correctly (is y a vowel? what are the exact constraints?) //look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) public class Main...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
a9b80484d5aecb33d81c50cdebc46782
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; String[] ar; StringBuilder sb = new StringBuilder(); ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
7874e848a89f1be56f4dba12f256ae99
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { 1, 0, -1, 0 }; private static int dy[] = { 0, -1, 0, 1 }; private static final long INF = Long.MAX_VALUE; private static final int INT_INF = Integer.MAX_VALUE; ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
06029aef711c34f0a14e40168c44304e
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.*; import java.util.StringTokenizer; @SuppressWarnings("WeakerAccess") public class Main { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] ar...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
a4a65bfaa4eacc66d8749da5bcd5dfc3
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.Arrays; import java.io.*; import java.util.*; public class Queries { public static void main(String args[]) { MyScanner in = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); String line = in.nextLine(); char[] arr = makePali(line); System.out.println(ne...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
54bc4d52068ceec46e6855019ee1fa6d
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces { static InputStreamReader isr = new InputStreamReader(System.in); static BufferedReader br = new BufferedReader(isr); // static PrintWriter pt = new PrintWriter(System.out); public static void main(String[] args) throws IOException { ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
d102bca31f095c9b73ae3dc10a483fe9
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.*; import java.util.*; public class C { static InputStreamReader isr = new InputStreamReader(System.in); static BufferedReader br = new BufferedReader(isr); // static PrintWriter pt = new PrintWriter(System.out); public static void main(String[] args) throws IOException { ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
39af325d32205157e0532a096ab745d8
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main (String[] args) { /* code */ Scanner scan = new Scanner(System.in); String s = scan.next(); int arr[] = new int[26]; for(int i=0;i<s.length();i++) { arr[s.charAt(i)-'a']++; ...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
f9736240f4150f2b302d979e1d6b5bd0
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
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.Random; import java.util.StringTokenizer; public class Solution{ public static void main(String[] args) throws IOExcep...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
9f7a54b6cfc75d3abbee784f47048bac
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.TreeSet; /** * Created by tignatchenko on 15.10.2015. */ public class Z1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
3611ce8d7eddb3a4aedad88652470a6a
train_000.jsonl
1448636400
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.You are given string s consisting of lowercase Latin letters. At once you can choose any position in the ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; import java.util.List; public class _v30{ public static void main(String args[]){ PrintWriter out = new PrintWriter(System.out); Reader in = new...
Java
["aabc", "aabcd"]
2 seconds
["abba", "abcba"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
f996224809df700265d940b12622016f
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
1,800
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
standard output
PASSED
49d23f893899d4e73034923db3fc20cd
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.*; import java.io.*; public class Main { static class Four{ int x , y , r , l ; public Four(int x , int y , int l , int r) { this.x = x; this.y = y; this.l = l; this.r = r; } } public static int mod = 1000000007; public static void solve(InputReader in) { int n = in...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
9da0bfe8ac8a6c86cd888d2614f0c430
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; /** * Created by Moi on 14-10-18. */ public class D { static int n, m, r, c, x, y; static boolean osbtacle[][]; static boo...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
e3ed3e816792056d3fbe4060b47edcd5
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.*; public class ProblemD { static class Point { int x = 0; int y = 0; int l = 0; int r = 0; public Point(int x, int y, int l, int r) { this.x = x; this.y = y; this.l = l; this.r = r; } } pub...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
0f93fa21c48b249b292d908964cba9bf
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
//Labyrinth //iterative bfs import java.io.*; import java.util.*; public class B1063b{ public static int n,m,xi,yi,left,right; public static char[][] board; public static boolean[][] used; public static int[][] movesl,movesr; public static void main(String[] args)throws IOException{ Buffer...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
3ef929becd8bab72b28ad4320bc52dcb
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.AbstractCollection; import java.util.Scanner; import java.util.LinkedList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author xwchen */ public class Main { ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
04fbd5defc2c2162ae90e683d8a362b3
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class tt_3 { static Scanner sc; static int n; static int m; static int r; static int c; static int max_l; static int max_r; static boolean[][] visitedPoints; static int[][][] leftRightVals; pu...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
90af2f462c7ee25cdd09ac3ea9a6d903
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader.init(System.in); new Main(); } Main() throws IOException { solve(); } void solve() throws IOException { PrintWriter out = new PrintWriter(...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
44569d87ec1f2c70c7fac5a816f310e7
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.*; import java.util.*; public class Main { long MOD = (long)1e9 + 7; public static void main(String[] args) throws IOException { Reader.init(System.in); new Main(); } Main() throws IOException { solve(); } void solve() throws IOException { Prin...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
498abddb6ac78398fb4204ada2cf8ee7
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Soly { static final int INF = Integer.MAX_VALUE; static int mergeSort(int[] a,int [] c, int begin, int end) { int ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
cf09f98ca8762cd318c04849001d75ca
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { FastReader reader = new FastReader(); PrintWriter writer = new PrintWriter(System.out); int n = reader.nextInt(); int m = reader.nextInt(); int r = reader.nextInt()-1; int c = reader.nextInt()-1; long[...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
2bf2557ef16bdad180a6bf42851a5411
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
//Labyrinth //iterative bfs import java.io.*; import java.util.*; public class B1063b{ public static int n,m,xi,yi,left,right; public static char[][] board; public static boolean[][] used; public static int[][] movesl,movesr; public static void main(String[] args)throws IOException{ Buffer...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
c7efe4d436216c80961f879f329ee58f
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
/** * Created by Aminul on 10/14/2018. */ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Queue; public class D_3 { public static void main(String[] args)throws Exc...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
3c6e0688fabf1bf665af0033c67e29d8
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.Deque; import java.util.LinkedList; import java.util.Scanner; public class Main { private static class Position { public int x , y; public Position(int x , int y) { this.x = x; this.y = y; } } private static String[] input = new String[2010]; private static int[][] leftDist = new ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
723c9f88ceabe876397a4f8d7d8a68e0
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.PriorityQueue; import java.util.Scanner; public class Main { private static class Element implements Comparable<Element> { public int x , y; public int cnt; public Element(int x , int y , int cnt) { this.x = x; this.y = y; this.cnt = cnt; } @Override public int compareTo(Elemen...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
92ebf89d439bafeb4d407281226cc72b
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
//package baobab; import java.io.*; import java.util.*; public class D { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve(); ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
b41e756ecbe0b68434df957ca92fc687
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out)); // String fileName = "C-small-attempt0"; // ConsoleIO io = new ConsoleI...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
b5d853252126d0d47d16c8ae971b3d12
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.StringTokenizer; public class Labyrinth implements Closeable { private InputReader in = new ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
4e28a34ba643c3aa73892b4c51df9e62
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.AbstractCollection; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.util.LinkedList; import java.io.InputStreamReader; import java.io...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
0977c712cfa049c19c61c61447731c38
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 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.util.InputMismatchException; import java.io.IOException; import java.util.AbstractCollection; import java.io.Writer; import java.io.Out...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
8c8ea106d493a6ada40e5518cf668ef4
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.BufferedInputStream; import java.util.Comparator; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; public class Main { static int [] dx={1,0,-1,0}; static int [] dy={0,1,0,-1}; static int n,m,x,y; static String[] map =new String[2...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
67ceb4157bae310ec2b7aa4dc87bb185
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
// TO LOVE IS TO KNOW WHAT'S YOUR WORTH. // // Author :- Saurabh// //BIT MESRA, RANCHI// import java.io.*; import java.util.*; import static java.lang.Math.*; public class labyrinth { static long ans=0; static int ar[][];static data vis[][];static int r,c,left,right; static void Bolo_Jai_Mata_Di() { ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
121d9656acd47c7290f68f2203ef9b0c
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
/** * BaZ :D */ import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static MyScanner scan; static PrintWriter pw; public static void main(String[] args) { new Thread(null,null,"BaZ",1<<25) { public void run() { t...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
a02cc10c10eea5844bc5164f1f2ad1fc
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 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.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.Arr...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
bd584f2735f40e6d4b944ff880d9b002
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Deque; import java.util.InputMismatchException; import java.util.StringTokenizer; public class ...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
de53bd5498e8ae5e743742c24f660163
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
import java.util.*; import java.io.*; public class Labyrinth { static BufferedReader br; static StringTokenizer tokenizer; static int[] xOff = {0,0,-1,1}; static int[] yOff = {1,-1,0,0}; static int[] lOff = {0,0,-1,0}; static int[] rOff = {0,0,0,-1}; public static void main(String[] args) throws Exception { b...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
a0d7400dfaec0fbf1f71a0e90ba30e1d
train_000.jsonl
1539511500
You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not o...
512 megabytes
//package CodeForces.Round516_div2; import javafx.util.Pair; import java.util.LinkedList; import java.util.Scanner; /** * @Author: tianchengjiang * @Date:2018/10/17 */ public class problemD { public static Scanner sc = new Scanner(System.in); public static Integer n; public static Integer m; publi...
Java
["4 5\n3 2\n1 2\n.....\n.***.\n...**\n*....", "4 4\n2 2\n0 1\n....\n..*.\n....\n...."]
2 seconds
["10", "7"]
NoteCells, reachable in the corresponding example, are marked with '+'.First example: +++..+***.+++***+++. Second example: .++..+*..++..++.
Java 8
standard input
[ "shortest paths", "graphs" ]
cfdbe4bd1c9438de2d871768c546a580
The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively. The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell. The third line contains two integers x, y (0 ...
1,800
Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.
standard output
PASSED
e91e795c55d91c86376c5feb1ab03fe3
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] arg...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
ff1535f905ccf4ba4070df6e9c11906d
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class CF1328D { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int q = Integer...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
6d78a305c756938efa2b2e661a19b55a
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcep...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
3cb532da3f4858ff2c938b39d1c414b4
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solve8 { public static void main(String[] args) throws IOException { Prin...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
01e96e5791fccd3163350d98ef6399a2
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Solve8 { public static void main(String[] args) throws I...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
8e6649f8353cf0e959097301f9fa954c
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public class D { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); StringBuilder sb = new StringBuilder(); for (int r = 0; r < t; r++) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextIn...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
db6fc76489bff6d908d49cb99dc2ccd7
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import javafx.util.Pair; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class D { public static void solve(int testCase, Reader in, PrintWriter out){ int n = in.nextInt(); int []ar = new int[n]; ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
2ab80aa023b7b772d2813d815b466639
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; import java.awt.*; public class Main implements Runnable { @Override public void run() { try { new Solver().solve(); System.exit(0); } catch (Exception | Error e) { e.printStackTrace(); Sys...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
b316e6f0c010c0e2e1ea274f47b923f1
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf131 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private in...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
46c6efd2504ee506ba223fa14ee593ec
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; public class CF1328D extends PrintWriter { CF1328D() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1328D o = new CF1328D(); o.main(); o.flush(); } void main() { int q = sc.nextInt(); while (q-- > 0) { int n = sc....
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
ad7cff586eae61ce30fa6cc94c58bfd9
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); U...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
b80d4144b7ff74f8460be3f3fc4e5d2e
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class D { public void run() throws Exception { FastScanner f = new FastScanner(); int t = f.nextInt(); while(t-->0) { int n = f.nextInt(); int[] animals = new int[n]; int[] colors = new int[n]; for(int i = 0; i <...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
5cae924c1988663af45ea5b71dc9f041
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; public class gym{ static int[][][]memo; static int n; static int dp(int i,int start,int prev) { if(i>=n)return 0; if(memo[i][start][prev]!=-1)return memo[i][start][prev]; if(i==n-1) { for(int c=1;c<=3;c++) { if(in[i]!=in[i-1] && c==prev)continue; if(in[i]!=in...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
8728f2656e62fbba5e1e89986fed345a
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
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.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelp...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
92e5b68392af1ee822e8a37d2a8d309d
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public final class Carousel { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { int n = sc.nextInt(); int[] animal = new int[n]; for (int j = 0; j < n; j++) { animal[j] = sc.nextInt(); } int[] ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
4374029fb19f61f706e0141607d4474b
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class P4 implements Runnable { public static void main(String args[]) throws Exception { new Thread(null, new P4(),"P4",1<<27).start(); } public void run() { In...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
2a4734bf6a36574313d8325c05176b03
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.Scanner; public class Carousel { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int cases = scanner.nextInt(); for (int c = 1; c <= cases; c++) { solve(); } } private static void solve() { ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
19f45d24fd99310be48b0a36a24e49fa
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
/** * @author egaeus * @mail sebegaeusprogram@gmail.com * @veredict * @url * @category * @date **/ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Int...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
97fe3415ee15edfd5a8094ae1272bafd
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.Scanner; public class carousel { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); StringBuilder finAns = new StringBuilder(); while (--q >= 0) { StringBuilder ans = new StringBuilder(); int n = sc.nextInt(), t[] = new int[n], flag = 0;...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
986c71d00781a470aa3cec05cca33368
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public class Carousel{ public static void main(String[] args){ Scanner sc= new Scanner(System.in); int t= sc.nextInt(); while(t-->0){ int n= sc.nextInt(); int[] type= new int[n]; for(int i=0;i<n;i++){ type[i]= sc.nextInt(); } boolean same= true; int[] group= null; ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
3cd5a01fddd21193f8dcb8a0db802b7a
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.text.*; /* Name of the class has to be "Main" only if the class is public*/ public class D { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Bu...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
a148674e7bccdd88e76b38086767bede
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; public class HelloWorld{ public static void main(String []args)throws IOException{ BufferedReader re = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(re.rea...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
d6a941b2affd28165dc989347cc85720
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1328d { public static void main(String[] args) throws IOException { int t = ri(); while(t --> 0) { int n = ri(), c[] = ria(n), ans[] = new int[n]; boolean...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
9be6f752513d2fd2cecb7cc67a8a904c
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
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. */ /** * * @author LUCIANO. */ import java.util.*; public class Solve { /** * @param args the command line arguments *...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
48fb939fd939d1ee077e111c4d0e066a
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class A { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
fb3b7bfa4d8f3dcd70b8f69f3bb11fc9
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
//package com.company; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t =input.nextInt(); for(int j =0;j<t;j++) { int n =input.nextInt(); int[] arr=new int[n]; ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
593edb8285d3c3bd6e93633effdf6aad
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import javax.print.DocFlavor; import java.awt.*; import java.io.*; import java.math.*; import java.util.*; public class Codeforce { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStr...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
63120c2828fe0ad3dd469d097e8e1349
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public class ProblemD { public static void main(String[] args) { Scanner s = new Scanner(System.in); int cases = s.nextInt(); for (int i = 0; i < cases; i++) { int n = s.nextInt(); int[] ar = new int[n]; for (int j = 0; j < n; j++) { ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
cd084898c1509b0a65f0b393b23458a5
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public final class Enraged { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
f743fa5b952d5930c42663061b0698ab
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.Scanner; public class Main { private static final int maxn = 200005; static Scanner in = new Scanner(System.in); private static int a[] = new int[maxn], ans[] = new int[maxn]; public static void main(String[] args) { int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); for (i...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
c9d77d595f7dbdf9c410779a484e0f2e
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.lang.reflect.Array; import java.util.*; import java.io.*; public class D629 { public static void main(String [] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int q = sc.nextInt(); while (q > 0) { ...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
bbaf1958f71390dba2b3fa8f42bcfe58
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public class div3_march_26_contest_629 { public static void main(String[] args) { Scanner scn=new Scanner(System.in); int t=scn.nextInt(); while(t-->0) { int n=scn.nextInt(); int[]arr=new int[n]; HashSet<Integer>set=new HashSet(); for(int i=0;i<n;i++) { arr[i]=scn.nextInt();...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
2303a87ab7a1b1ff0409b7bd4ba2fd00
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
256 megabytes
import java.util.*; public class Test { public static void main(String []args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t>0) { t--; int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; a[...
Java
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
71ed40bfc8c0bb118a81af2380be6d9b
train_000.jsonl
1585233300
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
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
["4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10"]
2 seconds
["2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1"]
null
Java 11
standard input
[ "dp", "greedy", "graphs", "constructive algorithms", "math" ]
1f4c3f5e7205fe556b50320cecf66c89
The input contains one or more test cases. The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the test. Then $$$q$$$ test cases follow. One test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the...
1,800
Print $$$q$$$ answers, for each test case print two lines. In the first line print one integer $$$k$$$ — the minimum possible number of distinct colors of figures. In the second line print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le k$$$), where $$$c_i$$$ is the color of the $$$i$$$-th figure. If ther...
standard output
PASSED
32ed87aee34dbece42a515054fdea930
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.util.Arrays; import java.util.ArrayDeque; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.FileReader; import java.io.IOException; import java.util.StringTokenizer; /**...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
d6a3121319b13377f93d8af81fe47c68
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.util.*; import java.awt.geom.*; import java.io.*; import java.math.*; public class Main { static final int n_max = 200010; static Scanner fi = new Scanner (System.in); static PrintWriter fo = new PrintWriter (System.out); static int[] L = new int[n_max], R = new int[n_max],...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
f09a94bf177c3e030383e2ff2c633b39
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.Comparator; import java.util.TreeSet; import java.io.InputStream; /** * Built using CHelper pl...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
886aec00ae0dd3ca84829dfc537e8671
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.ut...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
17a2dde1fb3767300baad8ed21ed203d
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class B547 { public static int mod = 1000000007; public static long INF = (1L << 60); static FastS...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
fe04518694fd00de5498749dad0abccd
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
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.List; import java.util.StringTokenizer; import java.util.stream.Stream; public class Solution imple...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
8d9b9341612f2382d7f77e77d3a72cfd
train_000.jsonl
1432658100
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears is a non-empty contiguous segment of the line. The size of a group i...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main (String [] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt() ; int [] a = new int [n] ; Compressor<Integer> ...
Java
["10\n1 2 3 4 5 4 3 2 1 6"]
1 second
["6 4 4 3 3 2 2 1 1 1"]
null
Java 8
standard input
[ "dp", "dsu", "binary search", "data structures" ]
5cf25cd4a02ce8020258115639c0ee64
The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears. The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.
1,900
Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.
standard output
PASSED
0a40522901c71643594b1879a99b1699
train_000.jsonl
1517582100
Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r — for every replace ai with D(ai); SUM l r — calculate . Pri...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; private PrintWriter pw; private long mod = 100...
Java
["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"]
2 seconds
["30\n13\n4\n22"]
null
Java 8
standard input
[ "data structures", "dsu", "number theory", "brute force" ]
078cdef32cb5e60dc66c66cae3d4a57a
The first line contains two integers n and m (1 ≤ n, m ≤ 3·105) — the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-...
2,000
For each SUM query print the answer to it.
standard output
PASSED
8140c5fc7216f8d4a2b533cf61eb022b
train_000.jsonl
1517582100
Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r — for every replace ai with D(ai); SUM l r — calculate . Pri...
256 megabytes
import java.io.*; import java.util.Random; import java.util.StringTokenizer; import java.util.TreeSet; public class G { public static void main(String[] args) { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); int t = 1; ...
Java
["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"]
2 seconds
["30\n13\n4\n22"]
null
Java 8
standard input
[ "data structures", "dsu", "number theory", "brute force" ]
078cdef32cb5e60dc66c66cae3d4a57a
The first line contains two integers n and m (1 ≤ n, m ≤ 3·105) — the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-...
2,000
For each SUM query print the answer to it.
standard output