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
7ddc7001004d305f7b76733ce556fd8a
train_003.jsonl
1461515700
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
256 megabytes
import java.io.*; import java.util.*; public class littleartemmatrix { private static InputReader in; private static PrintWriter out; static class Query { public int t,r,c,x; public Query(int t, int r, int c, int x) { this.t = t; this.r = r; this.c = c; this.x = x; } publi...
Java
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
2 seconds
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
null
Java 8
standard input
[ "implementation" ]
f710958b96d788a19a1dda436728b9eb
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
1,400
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
standard output
PASSED
d70382c6bfb28f4c371aaad17fcb56af
train_003.jsonl
1461515700
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.BufferedReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.IOException; /** * Built using CHelper plug-in * Actual soluti...
Java
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
2 seconds
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
null
Java 8
standard input
[ "implementation" ]
f710958b96d788a19a1dda436728b9eb
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
1,400
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
standard output
PASSED
95dfcea31600be80feb803991f4017c2
train_003.jsonl
1461515700
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class A { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; String FInput=""; void openInput(String file) { if(file==null)is = new BufferedRead...
Java
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
2 seconds
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
null
Java 8
standard input
[ "implementation" ]
f710958b96d788a19a1dda436728b9eb
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
1,400
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
standard output
PASSED
c33098fffcabb2ca425c911f4c3861a5
train_003.jsonl
1461515700
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
2 seconds
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
null
Java 8
standard input
[ "implementation" ]
f710958b96d788a19a1dda436728b9eb
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
1,400
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
standard output
PASSED
81848b929ef320838c19ccaf528f72ae
train_003.jsonl
1461515700
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.SynchronousQueue; public class Round348_A { static final long MOD_10e9_PLUS_7 = 1_000_000_007L; // distributive over + - * (NOT /) public st...
Java
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
2 seconds
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
null
Java 8
standard input
[ "implementation" ]
f710958b96d788a19a1dda436728b9eb
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
1,400
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
standard output
PASSED
dfd179affab68cfb3c0cd2416f87c90c
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.math.BigInteger; import java.util.*; public class com { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next().trim(); char[] c = s.toCharArray(); long[] a = new long[300]; long res = 0; for(int i = 0; i<c.length; i++) a[c[i]]++; for(int i = ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
3f307dda916a5224c8d40d7350b55ae3
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.StringTokenizer; public class Main { public static...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
eb5442754adb1461a1d572fb7a820b42
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public class ChoosingSymbolPairs { public static void main(String[] args) throws IOException { //Locale.setDefault (Locale.US); Reader in = new Reader(); StringBuilder out = new StringBuilder(); int[] letters, digits; String s; ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
cfa48f5ed6c9a9ca7bca1da8a8b423c4
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.Scanner; public class B_50_Choosing_Symbol_Pairs { public static void main(String[] args){ Scanner input=new Scanner(System.in); String s=input.nextLine().trim(); long count=0; int[] alpha=new int[75]; for(int i = 0; i < s.length(); ++i){ char ch = s.charAt(i); int a=ch-48; count=c...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
f1ccc902e01a583a1451672ff05b438c
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader in =...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
be42c7999cc2ccf58bd3acce0887cef6
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Main { public static void main(String[] args) throws IOException { BufferedReader b = new BufferedReader(new InputStreamRead...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
2aa30937f31a8df788551ea749c08480
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader inp = new BufferedReader(new InputStreamReader(Syste...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
ef9af5042db746a6720f854c28978063
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class A { static int max = 100000; // compare class // static class compare { int a; int b; public compare(int a, int b) { t...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
c0b61f4b3cc9fea9ade0bc5adcf2d4ea
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamRea...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
cf605ab76624d2307716d88933891c5f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
//package main; import java.util.*; import java.io.*; import java.math.*; public class Main { static StringTokenizer st; static BufferedReader scan; static PrintWriter out; public static void main(String[] args) throws IOException{ // Scanner scanf = new Scanner(new File("input.txt")); //PrintStream outf = new P...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
8f0c12def03b772f4ce47f9758a2a4cd
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
//package main; import java.util.*; import java.io.*; import java.math.*; public class Main { static StringTokenizer st; static BufferedReader scan; static PrintWriter out; public static void main(String[] args) throws IOException{ // Scanner scanf = new Scanner(new File("input.txt")); //PrintStream outf = new P...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
2576e29d07f95727b197ef0a8f052ed2
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public class j { public static void main(String a[])throws IOException { Scanner b=new Scanner(System.in); int i=0,n=0; double m=0; String s; s=b.next(); double d[]=new double[125]; d[0]=0; n=s.length(); for(i=0;i<n;i++) d[(int)s.charAt(i)]++; for(i=0;i<125;i++) m+=Math.pow(d[i],2)...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
02c592949cee6c19e3c195bde891cc5b
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
/* * @Author: steve * @Date: 2015-03-26 23:57:24 * @Last Modified by: steve * @Last Modified time: 2015-03-27 00:13:53 */ import java.io.*; import java.util.*; public class ChoosingSymbolPairs { public static void main(String[] args) throws Exception{ BufferedReader entrada = new BufferedReader(new Input...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
e0de5f89110411971b44d5aefb1fcf3f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 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; public class Tas050B { public static void main(String... args) throws NumberFormatException, IOException { Solution....
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
8af09fb1c415913fb4cbea7197ef7f3f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
9185338eb2287a5146d3c5f2a085125f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); char alpha[] = s.nextLine().toCharArray(); char arr[] = new char[256]; Map<Character,Integer> map = new HashMap<Character,Integer>(); int c ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
2521b6213c2020962c600139fe63384c
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Zyflair Griffane */ public ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
d4e43875d3da62439b6789056b0aec0f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { // split de array public static int[ ] atoi( String cad ) { String read[] = cad.split( " " ); int res[] = new int[ read.length ]; for ( int i = 0; i < read.length; i++ ) { res[ i ] = Integer.par...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
818f421a6368e75815e5a1f878ac2641
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public class B50{ public static void main(String args[]){ Scanner in=new Scanner (System.in); String a=in.next(); ArrayList <String> b=new ArrayList<String>(); ArrayList <Long> c=new ArrayList<Long>(); long d=0l; int i,j; for (i=0;i<a.length();i++){ for (j=0;j<b.size();...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
dc071637459d2a44bbc4c3af1a605c2c
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.*; import java.io.*; public class cadenasrep{ public static void main(String args[]) throws IOException{ BufferedReader lector = new BufferedReader(new InputStreamReader(System.in)); String tmp = lector.readLine(); String charset = "abcdefghijklmnopqrstuvwxyz0123456789"; int vec[] = new int[150]; long ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
9c2bb6a0a7d1de6f60ce798234b47923
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; /** * * @author Prateep */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // TODO code applicati...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
727744ddef1c0a210f81681334da8c4f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.HashMap; import java.util.Scanner; public class B50 { private String ip; private Long result = 0L; private HashMap<Character, Long> charMap = new HashMap<>(); public static void main(String[] args) { B50 obj = new B50(); obj.init(); obj.compute(); System.out.println(obj.result); ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
42f6c347de32c9a874d521c40d83a392
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; import java.lang.String; public class Hello { public static void main(String...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
62f14af1b7e1537f9770f9b6b5460726
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CodeD { static class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
a9f63afbd5880f7f3a7c2fa96d2194dc
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.Scanner; public class B50 { public static void main (String args[]){ Scanner in = new Scanner(System.in); char a[] = in.next().toCharArray(); long ans = 0 ; long t[] = new long[200]; for(int i = 0 ; i < a.length;i++){ t[a[i]]++; } for(int i = 0 ; i < t.length;i++){ ans += t[i]*t[...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
aa35d87bc520a955111634c621bf11dd
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public class ChoosingSymbolPairs { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); String str = f.readLine(); long[] a = new long[36]; for (int i = 0; i < str.l...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
6fabebf4724ab84c968471b5a5338843
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map.Entry; import java.util.StringTokenizer; import javax.swing.text.html.HTMLDocument.Iterator...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
90f429327a5ac35992e401ffed77d57f
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { static BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); static StringTokenizer st = new StringTokenizer(""); static int nextInt() throws Exception { ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
50ae1420d045d9a0952dbfe2de2fedac
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public final class choosing_pairs { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); static int[][] bit; static int maxn=100000; static void update(int r,int c) { while(c<=maxn) { bit[r][c]++; c+=c&-c; } } static ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
8ddc583ff85edb6c72e1a2c28ff5af24
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.Scanner; public class B50 { public static void main (String args[]){ Scanner in = new Scanner(System.in); char a[] = in.next().toCharArray(); long ans = 0 ; long t[] = new long[200]; for(int i = 0 ; i < a.length;i++){ t[a[i]]++; } for(int i = 0 ; i < t.length;i++){ ans += t[i]*t[i...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
714eb393deb7bb12cf1b0ed7428df549
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long ans = 0; int []digit = new int [10]; int []character = new int [26]; String s = sc.next(); for (int i = 0; i < s.length(); i++) { if ('a' <= s.charAt(i) && s.charAt(i) <='z') ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
d4e7905906216b97e624a79decfa758d
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; //50_B public class Main { public static void main(String [] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); String s = rd.readLine(); long [] oc...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
5527d2d1b5aa2d9497f07a33ca13e798
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; import java.io.PrintWriter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.util.A...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
28c19bab30d78fca4d6f9a503e4e56d4
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.*; public class Main2 { public static void print(Object x) { System.out.println(x + ""); } public static ArrayList<String> readChars(String s) { ArrayList<String> out = new ArrayList<String>(); for (int i = 0; i < s.length(); i++) { out.add(s.substring(...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
acef1822ee9e8572d236bb262ca64672
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String s = bf.readLine(); long antwort = 0; TreeMap<Character, Long> counts = new TreeMap(); ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
8fcb66c9cb3de63903e0e8d6d6b765fa
train_003.jsonl
1292862000
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that1. 1 ≀ i, j ≀ N2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
256 megabytes
import java.util.Scanner; /** * * @author userx */ public class ChoosingSyymbolPairs { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.next(); char[] x = new char[s.length()]; boolean[] bo = new boolean[s.length()]; ...
Java
["great10", "aaaaaaaaaa"]
2 seconds
["7", "100"]
null
Java 7
standard input
[ "strings" ]
6bb2793e275426eb076972fab69d0eba
The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.
1,500
Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.
standard output
PASSED
efbdaae9e4042ec94157d3e7a065e966
train_003.jsonl
1559745300
At first, there was a legend related to the name of the problem, but now it's just a formal statement.You are given $$$n$$$ points $$$a_1, a_2, \dots, a_n$$$ on the $$$OX$$$ axis. Now you are asked to find such an integer point $$$x$$$ on $$$OX$$$ axis that $$$f_k(x)$$$ is minimal possible.The function $$$f_k(x)$$$ can...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /** * @author Tran Anh Tai * @template for CP codes */ public class ProbA { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new Input...
Java
["3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n4"]
2 seconds
["3\n500000000\n4"]
null
Java 11
standard input
[ "binary search", "greedy", "brute force" ]
87e39e14d6e33427148c284b16a7fb13
The first line contains single integer $$$T$$$ ($$$ 1 \le T \le 2 \cdot 10^5$$$) β€” number of queries. Next $$$2 \cdot T$$$ lines contain descriptions of queries. All queries are independent. The first line of each query contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k &lt; n$$$) β€” the...
1,600
Print $$$T$$$ integers β€” corresponding points $$$x$$$ which have minimal possible value of $$$f_k(x)$$$. If there are multiple answers you can print any of them.
standard output
PASSED
6ed950d0ee1b994055c85e44909c78da
train_003.jsonl
1559745300
At first, there was a legend related to the name of the problem, but now it's just a formal statement.You are given $$$n$$$ points $$$a_1, a_2, \dots, a_n$$$ on the $$$OX$$$ axis. Now you are asked to find such an integer point $$$x$$$ on $$$OX$$$ axis that $$$f_k(x)$$$ is minimal possible.The function $$$f_k(x)$$$ can...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class scratch_35 { static class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** * call this method to initialize reader for InputStream */ static void init(InputStream input) {...
Java
["3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n4"]
2 seconds
["3\n500000000\n4"]
null
Java 11
standard input
[ "binary search", "greedy", "brute force" ]
87e39e14d6e33427148c284b16a7fb13
The first line contains single integer $$$T$$$ ($$$ 1 \le T \le 2 \cdot 10^5$$$) β€” number of queries. Next $$$2 \cdot T$$$ lines contain descriptions of queries. All queries are independent. The first line of each query contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k &lt; n$$$) β€” the...
1,600
Print $$$T$$$ integers β€” corresponding points $$$x$$$ which have minimal possible value of $$$f_k(x)$$$. If there are multiple answers you can print any of them.
standard output
PASSED
2b4c7798795f8d576412ba4950fd2373
train_003.jsonl
1559745300
At first, there was a legend related to the name of the problem, but now it's just a formal statement.You are given $$$n$$$ points $$$a_1, a_2, \dots, a_n$$$ on the $$$OX$$$ axis. Now you are asked to find such an integer point $$$x$$$ on $$$OX$$$ axis that $$$f_k(x)$$$ is minimal possible.The function $$$f_k(x)$$$ can...
256 megabytes
import java.io.*; import java.util.*; import java.util.logging.Logger; import static java.lang.System.*; public class C1175 { static BufferedReader br; static long mod = 998244353; static HashSet<Integer> p = new HashSet<>(); public static void main(String[] args) throws Exception { br = ne...
Java
["3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n4"]
2 seconds
["3\n500000000\n4"]
null
Java 11
standard input
[ "binary search", "greedy", "brute force" ]
87e39e14d6e33427148c284b16a7fb13
The first line contains single integer $$$T$$$ ($$$ 1 \le T \le 2 \cdot 10^5$$$) β€” number of queries. Next $$$2 \cdot T$$$ lines contain descriptions of queries. All queries are independent. The first line of each query contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k &lt; n$$$) β€” the...
1,600
Print $$$T$$$ integers β€” corresponding points $$$x$$$ which have minimal possible value of $$$f_k(x)$$$. If there are multiple answers you can print any of them.
standard output
PASSED
87383145c9a5554d26de40dc058cfdbc
train_003.jsonl
1559745300
At first, there was a legend related to the name of the problem, but now it's just a formal statement.You are given $$$n$$$ points $$$a_1, a_2, \dots, a_n$$$ on the $$$OX$$$ axis. Now you are asked to find such an integer point $$$x$$$ on $$$OX$$$ axis that $$$f_k(x)$$$ is minimal possible.The function $$$f_k(x)$$$ can...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class C { public static void process(int test_number)throws IOException { int n = ni(), k = ni(), arr[] = new int[n + 1]; for(int i = 1; i <= n; i++) arr[i] = ni(); k++; Arrays.sort(arr, 1, n + 1); ...
Java
["3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n4"]
2 seconds
["3\n500000000\n4"]
null
Java 11
standard input
[ "binary search", "greedy", "brute force" ]
87e39e14d6e33427148c284b16a7fb13
The first line contains single integer $$$T$$$ ($$$ 1 \le T \le 2 \cdot 10^5$$$) β€” number of queries. Next $$$2 \cdot T$$$ lines contain descriptions of queries. All queries are independent. The first line of each query contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k &lt; n$$$) β€” the...
1,600
Print $$$T$$$ integers β€” corresponding points $$$x$$$ which have minimal possible value of $$$f_k(x)$$$. If there are multiple answers you can print any of them.
standard output
PASSED
213961bb02bf6f4df1fc60ff2cbf1f31
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class prop { static Scanner sc; static PrintWriter pw; static int n; static char c[][]; static int memo[][]; static boolean valid(int i, int j) { return (i < n && i >= 0 && j >= 0 && j < n); } static boolean dp(int i, int j, boolean f) { if (i == n || j == n)...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
68d8873cf3dd7abcfdac3c8e2a65a6ac
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Today1 { static void solve() throws IOException { int n = nextInt(), m = nextInt(), temp; if(n == 1) { out.println(nextLine()); return; } String s[] = new String[n]; for(int i = 0; i < n; ++i) s[i] = nextLine(); for(int ind = 0; ind < m; ++ind) {...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
12472ef1449a48938112a2db0d6f0b25
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
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
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
8cd15118e745585766d8f475a11d1b61
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
// package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int q = 0; q < t; q++){ int n = in.nextInt(), m = in.nextInt(); String slov[] = new String[n]; for(int ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
2c1d7f8a3ea2ca487df51861e5712ade
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
// practice with kaiboy import java.io.*; import java.util.*; public class CF1360F extends PrintWriter { CF1360F() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1360F o = new CF1360F(); o.main(); o.flush(); } static final int A = 26; boolean check(by...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
7caa2143d5603106a31912793bb27227
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main{ static long MOD = 1000000007L; static long [] fac; static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; static long lMax = 0x3f3f3f3f3f3f3f3fL; static int iMax = 0x3f3f3f3f; static HashMap <Long, Long> ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
8d58a693683e20b45a123bd065fe9bff
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Spy_String { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new S...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
8621f8b4b4481f7c8cc793c7fc038037
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Spy_String { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new S...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
312fb632b52f4323d5db2567c14f509b
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.* ; import java.lang.Math ; public class Main { public static void main (String [] args){ Scanner in = new Scanner (System.in) ; int t = in.nextInt() ; while (t-- > 0){ int n , m ; n = in.nextInt() ; m = in.nextInt() ; String [] b = new String [n] ; char [...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
550f8f50a69e0453bfc09b8704797927
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; public class Main{ static String func(String[] arr, int k) { String s = arr[0]; for(int i = 0; i < k; i++) { char[] carr = s.toCharArray(); for(int j = 0; j < 26; j++) { carr[i] = (char)('a' + j); boolean go = true; for(String str : arr) { int find = 0; for(int a = 0...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
a7cfd9e2e0787af32036e7d0234b3766
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.Scanner; public class cf1360_Div3_F { public static void main(String args[]) { Scanner in = new Scanner(System.in); int tc = in.nextInt(); for ( ; tc > 0; tc--) { int n = in.nextInt(); int m = in.nextInt(); char[][] grid = new char[n][]; for (int i = 0; i < n; i++) { grid[i] = i...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
f3094d4082b134dd81d1bd8d3e962e86
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static Boolean[][]memo; static int n,m; static char[][]in; static int[][]changes; static boolean dp(int i,int mask) { if(i>=m)return true; if(memo[i][mask]!=null)return memo[i][mask]; boolean ans=false; for(int c=0;c<26;c++) { int changesMsk=ch...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
9a426b66ef78dfec34f8212b96fe8789
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStream; /** * Built using CHelp...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
16e9e2bc720f631524326f88a618503c
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStream; /** * Built using CHelp...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
33000ec43926f2fc6786c7f278e6587c
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Q3 { private static boolean chk(char arr[][],char ref[]) { for(int i=0;i<arr.length;i++) { int temp=0; for(int j=0;j<arr[i].length;j++) { temp+=(arr[i][j]!=ref[j])?1:0; } if(temp>1) { return false; } } return true; } public stat...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
498b43f9661e35c7f03deabb4386ea31
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; public class Main { private static class FastScanner { private BufferedReader reader = n...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
56ce687e4687b945db8d47a0425c45a4
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static IO io; static StringBuilder solve(String[] arr, int n, int m) { StringBuilder ans = new StringBuilder(arr[0]); for(int i = 0; i < m; i++) { char save = ans.charAt(i); for(char c = 'a'; c <= 'z'; c++) { ans.setCharAt(i, c); boole...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
930ba7174868e33402481c23e53ea510
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.*; public class Solution { static int n,m; static char arr[][]; static boolean check(char ar[]){ for(int i=0;i<n;i++){ int c=0; for(int j=0;j<m;j++){ if(arr[i][j]!=ar[j]) ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
bd9accb92a584fdc8edbfad83aeaaee6
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
/** * @author egaeus * @mail sebegaeusprogram@gmail.com * @veredict Not sended * @url <https://codeforces.com/problemset/problem/> * @category ? * @date 24/05/2020 **/ import java.io.*; import java.util.*; import static java.lang.Integer.*; import static java.lang.Math.*; public class CFF { static int N,...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
045b10d0e29a82dabe5ef0bfa4b47b81
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Q3 { private static boolean chk(char arr[][],char ref[]) { for(int i=0;i<arr.length;i++) { int temp=0; for(int j=0;j<arr[i].length;j++) { temp+=(arr[i][j]!=ref[j])?1:0; } if(temp>1) { return false; } } return true; } public stat...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
9541b65f589180e87c64df54943921de
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.Scanner; public class Solution2 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); s.nextLine(); for (int i = 0; i < t; i++) { int n = s.nextInt(); int m = s.nextInt(); s.nextLine(); String[] arr = new String[n]; for (int j = 0;...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
477e4ae20c4743e79a92edc355abdbca
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; public class contest { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int i=0;i<t;i++) { int n=s.nextInt(); int m=s.nextInt(); String[] arr=new String[n]; for(int j=0;j<n;j++) { arr[j]=s.next(); } ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
3bc42f232dd3ecddf95513f95cc08a01
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
// Problem: F. Spy-string // Contest: Codeforces - Codeforces Round #644 (Div. 3) // URL: http://codeforces.com/problemset/problem/1360/F // Memory Limit: 256 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) import java.io.*; import java.util.*; public class Main { private...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
33e7d56d34721fd234d1c8e9e499c6d7
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.Reader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; impor...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
307ad3d6de7b698b03ab5be93ffef129
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); int t = nextInt(); for (int q = 0; q < ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
f81a747a46a2fabc0a6328a81b1d12f6
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
/** * @author vivek */ 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 Main { private static void solveTC(int __) { /* For Google */ // ans.append("Case #")....
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
088040cd168f984baffda923fb4f5735
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class F { static final boolean RUN_TIMING = false; PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok; public void go()...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
2f4a969d48d715a6f1e84214b0fc633e
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1360f { public static void main(String[] args) throws IOException { int t = ri(); next: while(t --> 0) { int n = rni(), m = ni(); char a[][] = new char[n]...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
24223767f0f566081e3029a2fae97b98
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class SolutionF { static BufferedReader input; static StringTokenizer _stk; static String readln() throws IOException { String l = input.readLine(); if (l != null) _stk = new StringTokenizer(l, " "); return l; } sta...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
abb65b9505c7dd0faacd4ff761903aa3
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Problem6 { public String findValid(String[] s, List<List<Character>> cs, int n, int m, int index, char[] x) { for (char l : cs.get(index)) { x[index] = l; if (index ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
25a81367e6074b1524240f3b88827c42
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import static java.lang.Math.*; public class round644_Solution_6 implements Runnable { private boolean console=false; private long MOD = 1000_000_007L; private int MAX = 1000_001; int n,m; char[][] arr; char[] temp; St...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
b670aa58da4c2b8f8e068f43753a124d
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedOutputStream; import java.io.UncheckedIOException; import java.nio.charset.Charset; import java.util.StringTokenizer; imp...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
4d62825ac35b40bd22b6f545e4ba62dd
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_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.Comparator; public class d extends PrintWriter{ static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); // static Scanner...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
2ce414d4f5de881080a3ea23e4aea368
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException { int test = GetInput.getInt(); while (test-...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
82739f4d3fbe3a1e159a2a20373e3242
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static Reader in = new Reader(); public static void main(String[] args) throws IOException { Main solver = new Main(); solver.solve(); out.flush(); ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
20b5d5772266871179887a37ef457300
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class Main { int n,m; char s[][]; private void solve()throws IOException { n=nextInt(); m=nextInt(); s=new char[n+1][m+1]; for(int i=1;i<=n;i++) { String s1=nextLine(); for(int j=1;j<=m;j++) s[i][j]=s1.charAt(j-1); } char temp[]=new char[m+1]; f...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
018e233f98bd39735aa47ad30adb3ae4
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; public class Main{ static String func(String[] arr, int k) { String s = arr[0]; for(int i = 0; i < k; i++) { char[] carr = s.toCharArray(); for(int j = 0; j < 26; j++) { carr[i] = (char)('a' + j); boolean go = true; for(String str : arr) { int find = 0; for(int a = 0...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
df15f56e8ff2d4eed069b307fec186fb
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
//I AM THE CREED /* package codechef; // don't place package name! */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; //I AM THE CREED /* package codechef; // don't place package name! */ import java.io.BufferedRead...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
5db2cd5d4f07f0ad869e3e6652178e35
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { var sc = new Scanner(System.in); int T = Integer.parseInt(sc.next()); var sb = new StringBuilder(); for(int t = 0; t < T; t++){ int n = Integer.parseInt(sc.next(...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
f0e4f49157f82f4cbac4f4852d9076e1
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.*; public class Main { public static void main(String[] args) ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
1806bbe0ca8889a046efff9a5454cdc8
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class F { static class Task { private char[][] grid; private int n; private int m; private boolean isOk(char[] targetArr) { for (int i = 1; i < n; i++) { int diffCount ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
695aa76b073cadc7c9f827ee51cc60e5
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; //Mann Shah [ DAIICT ]. public class Main { static long mod = (long) (1e9+7); static InputReader in; static PrintWriter out; static Debugger deb; public static int n,m; public static String ans="-1"; public static void recursion(i...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
ad8ce42341ab527cc6af3b9a62a0a77c
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; //Mann Shah [ DAIICT ]. public class Main { static long mod = (long) (1e9+7); static InputReader in; static PrintWriter out; static Debugger deb; public static int n,m; public static String ans="-1"; public static void recursion(i...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
9f9b36a88c8b7b3afda89d58ec535bcf
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { int t = sc.nextInt(); while(t-- > 0) solve(); out.close(); } private static void solve() { int n = sc.nextInt(); int m = sc.nextInt(); String[] strs = new String[n]; ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
f21ac5c139a14d1ac193e3cb045626dc
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Learning { public static void main(String[] args) throws Exception { FastInput in = new FastInput(); StringBuilder st = new StringBuilder(); int t = i...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
4acc35d33ee51338acc12f51f019ee3c
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public stati...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
4b08cce873df282474eae2e1c9a34de0
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Codechef { PrintWriter out; StringTokenizer st; BufferedReader br; class Pair implements Comparable<Pair> { int f; int s; Pair(int t, int r) { f = t; s = r; } public int compareTo(Pair p) ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
cffe71dbf6b9509d0d683f40f0859fa0
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Solution { static int n,m; static String[] s; static HashSet<Character> set[]; static String ans="0"; static char chk[]; public static void main(String[] args) throws Exception { FastReader sc =...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
63cb8e598383685f7181ce37d1ffc4a5
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; // CODE JAM SHIT public class Q2 { static int diff(String a,String b){ int p=0; for(int i=0;i<a.length();i++){ if(a.charAt(i)!=b.charAt(i)) p++; } return p; } public static void main(String[] args) { ...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
b3c54820bc480850afa1c77c52ac07a0
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve() { outer: for(int T = ni(); T > 0; T--)...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
98b746fa9a37b342b3de4b2944075f1e
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Six { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); Buff...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
ddd18673d95006d9681dd58dbcd35b16
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastRea...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
2fa814fade206bf1b837c91378e113a1
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.*; import java.util.*; /** * Built using my Brain * Actual solution is at the bottom * * @author Lenard Hoffstader */ public class cfjava { public static void main(String[] args) { OutputStream outputStream = System.out; FastReader in = new FastReader(); PrintWriter out = new Pri...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
5de72bf116f885bd02c44415bbc3c8df
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.util.*; import java.io.*; public class Spystring { // https://codeforces.com/contest/1360/problem/F public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new BufferedReader...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output
PASSED
a897eb72438b757a5d41c2ead6a0659b
train_003.jsonl
1590327300
You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i...
256 megabytes
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * * @author KIIT */ public c...
Java
["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"]
2 seconds
["abab\n-1\naaa\nab\nz"]
NoteThe first test case was explained in the statement.In the second test case, the answer does not exist.
Java 11
standard input
[ "dp", "hashing", "constructive algorithms", "bitmasks", "brute force", "strings" ]
8d4cdf75f726b59a8fcc374e1417374a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)Β β€” the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$)Β β€” the number of strings and their length. Then follow $$$n$$...
1,700
Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).
standard output