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
2e27a7045846b86f20684f1f2f65e20e
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.*; public class elections { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int n, m, bcan=0, psi=0; int[] can=new int[101]; n=in.nextInt(); m=in.nextInt(); int i, j, a; for(i=0; i<m; i++) { int o=0, kalo=0; for(j=...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
b9d7f3cfef5204e097fd4a139d0592dd
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; public class dpProblem2 { static int dp[][]; static boolean dpB[][][]...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
8373064b0b80315aa23ebe26e7484a34
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.util.*; public class DivideByThree { public static void main(String[] args) { Scanner in = new Scanner(System.in); String num_str= in.next(); char[] num = num_str.toCharArray(); int sum = 0; List<Integer> ones = new ArrayList<Integer>(); List<Integer> twos = new ArrayList<Integer>(); int ...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
d768bfce9af75d420a183aa66bed729a
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.util.*; public class DivideByThree { public static void main(String[] args) { Scanner in = new Scanner(System.in); String num_str= in.next(); char[] num = num_str.toCharArray(); int sum = 0; List<Integer> ones = new ArrayList<Integer>(); List<Integer> twos = new ArrayList<Integer>(); int ...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
32b9bdb881eae4d2402d48d697b8a667
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.io.PrintWriter; import java.lang.reflect.Array; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.Stack; import java.util.ArrayList; import java.util.Arrays; import java.lang.*; public cla...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
3650b7fe6e3b91e667660fe5c0d3a2b7
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.util.Scanner; public class R792C { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s=in.next(); int[] m=new int[3]; for(int i=1; i<3; i++) m[i]=0; int sum=0; boolean zero=false; for(int i=0; i<s.length(); i++)...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
bbbf0d3d39cc7e281ede83689095e0ba
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
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
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
141565791b539140d271fe3cbf482c7f
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); StringBuilder sb1 = new StringBuilder(s), sb2 = new StringBuilder(s); char num[] = s.toCharArray(); int sum=0; for(char c : num){ int t=c-'0'; sum+=t...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
5be213032509b961adcdc22f67e5f44c
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { private static int n; private static Integer dp[][][]; private static int p[][][]; private static String s; privat...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
9c531593d0ce533b58f87cf01a42e16d
train_001.jsonl
1490625300
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.The number is called beautiful if it consists of at least one digit, doesn't have leading zeroe...
256 megabytes
/* * Author Ayub Subhaniya * Institute DA-IICT */ import java.io.*; import java.math.*; import java.util.*; public class Driver { InputStream in; PrintWriter out; void solve() { String s=ns(); int n=s.length(); int sum=0; boolean containsZero=false; for (int i=0;i<n;i++) { sum=(sum+s.charAt(i...
Java
["1033", "10", "11"]
1 second
["33", "0", "-1"]
NoteIn the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
Java 8
standard input
[ "dp", "number theory", "greedy", "math" ]
df9942d1eb66b1f3b5c6b665b446cd3e
The first line of input contains n β€” a positive integer number without leading zeroes (1 ≀ n &lt; 10100000).
2,000
Print one number β€” any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.
standard output
PASSED
f2d4c7423919667634a32e9d8c3a450c
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int answer = 0; long min = 0; long max = 0; for (int i = 0; i < n; i++) { ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
737928371f2c1be30dcf98d5d184a3bb
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
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
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
edf46f04c7d6cd7799a3e58e4b9f0a08
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public class Main { InputStream is; PrintWriter out; String INPUT = ""; long MOD = 1_000_000_007; int inf = 10000000; void solve() { int n = ni(); int d = ni(); int[] a = new int[n]; ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
4853b7b870d9c7afe7855fdd1f8f24f5
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.*; public class CreditCard { public static void main(String[] args) throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); StringTokenizer st = new...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
338bdc85b660c344e0269452ab6855a3
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; public class ER33Dsubmission { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int d = scan.nextInt(); int[] arr = new int[n]; int[] sum = new int[n]; ST maxims = new ST(n); for(int i = 0; i < n; i++) arr[i] = scan.nextInt(); ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
3b84926b4ec906dc1d76490ae44530d3
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static long BFS(int cur, ArrayList<ArrayList<Integer>> con, boolean[] vis, long[] arr){ Q...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
e20dc5c2ba27364692a8680ce4955d7d
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader; static PrintWriter writer; public static void main(String[] args) { T...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
d4d171219030cb1c4a0c830167c0fb6e
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class EduD implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
1e78055c47d4200a8e0e9814457cecb4
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
d8b3c23815aa441187f58df9d19362dd
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class Ed_2017_R33_D { FastReader in; PrintWriter out; public static void main(String[] args) { new Ed_2017_R33_D().run(); } void run() { in = new FastReader(Syste...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
97d7dde9a03b91a244e514c060cbd6ce
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.BufferedInputStream; import java.util.Scanner; /** * Created by leen on 23/11/2017. */ public class _893D { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in, 1024*64)); int n = scan.nextInt(), d = scan.nextInt(); int[]...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
fa2d16a0ffa645770c66a03c42d59674
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Solution { public static void solve(InputReader in, PrintWriter out, DebugWriter debug) throws IOException { int n = in.nextInt(); long d = in.nextInt(); int[] a = in.nextIntArray(n); long[] balance = new long[n]; ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
f5a117564bc3ad6df499d72ae9e2b101
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
//893D //Credit Card import java.io.*; import java.util.*; public class D { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int d = sc.nextInt(); int[] arr = new...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
bfdd97f78d18d9121488875bf3d56311
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class P893D { public static void main(String[] args) { FastScanner scan = new FastScanner(); int n = scan.nextInt(); int d = scan.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
9194c6d82a66ab13551c8e6b7dca793e
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
//package cow17; /* LANG: JAVA TASK: */ import java.io.*; import java.util.*; public class cf4 { public static void main(String[] args) throws IOException { Scanner c = new Scanner(System.in); int N = c.nextInt(), D = c.nextInt(); long[] arr = new long[N]; for(int i=0; i<N; i++) arr[i] = c.nextLong(); lon...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
0a04a70ad13f63f84f7b268463f7031c
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
/** * Created by Chirag on 17-12-2017. * DA-IICT (B.tech 3rd year) */ import java.io.*; import java.util.*; public class CreditCard { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); /* ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
5c5194be0df2773620f804a92587a4f7
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
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 * * @author Jenish */ public class Ma...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
cf95d5b9ac7d9e4f36c3cc9fe4632678
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import com.sun.org.apache.regexp.internal.RE; import java.io.*; import java.nio.file.ClosedWatchServiceException; import java.security.SecureRandom; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamRea...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
03d83de38b5c16ab60ff25851be891ff
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.StringToke...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
e7f5debf7ce32fe73ba561536ec6b991
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
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
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
f653356612cde7fd814cacec8d8d5043
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; public class ER33Dsubmission { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int d = scan.nextInt(); int[] arr = new int[n]; int[] sum = new int[n]; ST maxims = new ST(n); for(int i = 0; i < n; i++) arr[i] = scan.nextInt(); ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
fa0ca5c22cafeb201694cb3af0ea09d7
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
/* * Remember a 7.0 student can know more than a 9.8 student. * Grades don't determine intelligence, they test obedience. * I Never Give Up. */ import java.util.*; import java.io.*; import java.util.Comparator.*; import static java.lang.System.out; import static java.util.Arrays.sort; import static java.lang.Mat...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
91a37379ed4481d8194a6da6b2f56f71
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
/* * Remember a 7.0 student can know more than a 9.8 student. * Grades don't determine intelligence, they test obedience. * I Never Give Up. */ import java.util.*; import java.io.*; import java.util.Comparator.*; import static java.lang.System.out; import static java.util.Arrays.sort; import static java.lang.Mat...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
bff8a12a587e3dc663e743ca44e52154
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.*; public class icpc { public static void main(String[] args) throws IOException { Reader in = new Reader(); //BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = in.nextInt(); long d = in.nextLong(); long[...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
e435ef0b1637f8dcea555b4fdda9513d
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.PrintWriter; import java.util.*; /** * Created by trung.pham on 25/12/17. */ public class D_Edu_Round_33 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int d = in.n...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
8ad7e8f0134fad52c5996c6648183d2c
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.regex.*; public class Main{ public static void main(String[] args) { InputReader in=new InputReader(System.in); PrintWriter pw = new PrintWrit...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
e9f13b665deb0059563a3f0c2240eb4c
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Stack; public class Tester { In...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
3908c51b745a4a65b73b4a387baa2a4c
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class main { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
941676e62105a9053b1781d874a991ff
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.StringTokenizer; public class Edu33D { public static void main(String[] args) { FS scan = new FS(System.in); int N = ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
b2fb6d0d4942baedb8573dbe51764d03
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; /* public class _893D { } */ public class _893D { public void solve() throws FileNotFoundException { InputStream in...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
ea89b6036c9b7c135c411e347014c744
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main{ static final long MOD = (long)1e9+7; static FastReader in; static int MAX = (int)1e6; static ArrayList<Integer>[] adj; public static void main(String[] args){ in = new FastReader(); int N = ni(); lon...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
23f8edfbc5affecb854127682ecd24b6
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main{ static final long MOD = (long)1e9+7; static FastReader in; static int MAX = (int)1e6; static ArrayList<Integer>[] adj; public static void main(String[] args){ in = new FastReader(); int N = ni(); lon...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
06ada39be9527c1033239cecc6f89ac7
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFi...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
78434875fd4520fe9fc2d2f2bbc8f250
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.Scanner; /** * D. ΠšΡ€Π΅Π΄ΠΈΡ‚Π½Π°Ρ ΠΊΠ°Ρ€Ρ‚Π° * http://codeforces.com/problemset/problem/893/D */ public class Task1_893D { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long days = scanner.nextLong(); long d = scanner.nextLong(); long ma...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
6343048b30c5051cb965a7b1ff343da1
train_001.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
//package educational.round33; 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 D { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 8
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≀ n ≀ 105, 1 ≀ d ≀ 109) β€”the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≀ ai ≀ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
b44e490c9fca5165daa484c28ee8aa1b
train_001.jsonl
1368784800
You get to work and turn on the computer. You start coding and give little thought to the RAM role in the whole process. In this problem your task is to solve one of the problems you encounter in your computer routine.We'll consider the RAM as a sequence of cells that can contain data. Some cells already contain some d...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class Solve6 { public static void ma...
Java
["5 3\n8 4 3 2 2\n3 2 2", "10 6\n1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0"]
2 seconds
["2", "6"]
NoteIn the first example you are given memory clusters with sizes 8, 4, 3, 2, 2 and arrays with sizes 8, 4, 4. There are few ways to obtain an answer equals 2: you can locate array with size 8 to the cluster with size 8, and one of the arrays with size 4 to the cluster with size 4. Another way is to locate two arrays w...
Java 11
standard input
[ "binary search", "bitmasks", "greedy" ]
e95fb7d4309747834b37d4bc3468afb7
The first line of the input contains two integers n and m (1 ≀ n, m ≀ 106). The next line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 109). The next line contains m integers b1, b2, ..., bm (1 ≀ 2bi ≀ 109).
1,900
Print a single integer β€” the answer to the problem.
standard output
PASSED
eb455c990bf384a71acf26beb2c8332d
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
3ee4f3aad8ccb82daace7a82473859c4
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static char[][] array; public static char[] spare; public static int vo=-2; public static boolean sorted(char[][] array, int row) { int flag=0; for(int i=1; i<row; i++) { String s1="",s2=""; for(int u=0; u<array[0].length;u++) { ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
357759e8f58d63a4910326490ef02df3
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); char[][] table = new char[n][m]; for (int r = 0; r < n; r++) { String line = sc.next(); for (int c...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
1646e8603cb868667f9b2c82f2b91bc7
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
/** * ******* Created on 7/12/19 8:22 PM******* */ import java.io.*; import java.util.*; public class C469 implements Runnable { private static final int MAX = (int) (1E5 + 5); private static final int MOD = (int) (1E9 + 7); private static final int Inf = (int) (1E9 + 10); private void solve() th...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
73e743ab8ec2ed37a17978bf7f4b8f50
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(), m = in.nextInt(); char[][] t = new char[n][m]; for (int i = 0; i < n; i++) ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
fef4c7e95c83ad52e33cd4b901f841c7
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class C496 { public static int mod = 1000000007; static Fa...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
1275e5c74a10bbe04e7f0b83dbfd4d34
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
/* *created by Kraken on 26-04-2020 at 14:01 */ //package com.kraken.cf.practice; import java.util.*; import java.io.*; public class C496 { public static void main(String[] args) { FastReader sc = new FastReader(); int n = sc.nextInt(), m = sc.nextInt(); char[][] mat = new char[n][]; for (int i =...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
0e9c68988fd1e4599405a1309b19ca5c
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Arrays; import java.util.Scanner; /** * * @author team02 */ public class C { /** * @param args the comm...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
6ea710ce4af2fd03b56bb652c70b996e
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.*; import java.util.*; public class CF_496_C_REMOVING_COLUMNS { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); HashSet<Integer> set = new HashSet<>(); int n = sc.nextInt(); int m = sc.nextInt(); String[] a = new String[n]; for (int i = 0; i < n; ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
340f7929e377204e4763ef9c44dbd240
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Euler { public static int check(char[] a, char[] b) { int n = a.length; int i = 0; while (i < n && a[i] == b[i]) i++; if (i < n) { if (a[i] > b[i]) { return i; } } return -1; } public static void main(String[] ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
7c445bd607d6daceafe97b0b34ce04c2
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.File; import java.util.Scanner; import java.util.StringTokenizer; public class p034 { public static void main(String args[]) throws Exception { // StringTokenizer stok = new StringTokenizer(new Scanner(new File("C:/Users/Arunkumar/Downloads/input.txt")).useDelimiter("\\A").next()); StringTokenizer ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
ff3bb90737abdfdbb84cd0ba12f8ff19
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class RemovingColumns { static int n; static int m; static boolean[] rm; static char[][] arr; public static void main(String[] args) throws IOExcepti...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
4789f7af74bcdfa0cd5ef6174abd8fd3
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.BitSet; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputReader in ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
d9ffda80e93701871d4046c079934358
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
fc56c19070b8d4413feb246ecce8fe9e
train_001.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijkΒ we obtain the table:acdefghjkΒ A table is...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { 1, 0, -1, 0 }; private static int dy[] = { 0, -1, 0, 1 }; private static final long INF = Long.MAX_VALUE; private static final int INT_INF = Integer.MAX_VALUE; ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "constructive algorithms", "implementation", "brute force" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers Β β€” n and m (1 ≀ n, m ≀ 100). Next n lines contain m small English letters eachΒ β€” the characters of the table.
1,500
Print a single numberΒ β€” the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
6172c5e6d852a3f82784c00d6d9d45bd
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine().trim()); for(int u=0;u<t;u++) { ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
b692facfffb3320b551f45cf54f79555
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine().trim()); StringBuffer sb=new StringBuffer(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
4fdf7659125ed08fea0a2214dcc28bbb
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; import static java.util.Arrays.sort; import static java.util.Comparator.comparingLong; public class Main { FastScanner in; PrintWriter out; private void solve() throws IOException { int n...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
f7ed13a1963f444b994dedc1bfd0887b
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; import static java.util.Arrays.sort; import static java.util.Comparator.comparingLong; public class Main { FastScanner in; PrintWriter out; private void solve() throws IOException { int n = ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
6d33b8092702031a26d99286d5463f7a
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
//package CodeforcesProject; import java.io.*; import java.lang.*; import java.util.*; public class Main extends IO { public static void main(String[] args) throws Exception { StringBuilder word = new StringBuilder(".abcdefghijklmnopqrstuvwxyz"); Map<String, Pair> answer = new TreeMap<>(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
89fb0306c6b09a10aa5549ded9858277
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.math.*; // **** E. Polycarp and snakes **** public class E { static char [] in = new char [1000000]; public static void main (String [] arg) throws Throwable { int t = nextInt(); StringBuilder b = new StringBuilder(t * 100); for (int ii = 0; ii<t; ++ii) { int n = nextInt(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
e1811858bec4d4f72b6729eace4f496e
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; public class Main { public static int ran; public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); for(int i = 0; i < n; i++) { test(stdin); } //test(stdin); stdin.close(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
e465b4e82c5d084ddd47e8e89b39a30b
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; imp...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
9f71bd6d789f305f55519f3d6dcc4736
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.*; public class code0 { private static boolean oj = ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
00c48ef4aa955bf609fba03fc94b45f7
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static Integer INT(String s){ return Integer.parseInt(s); } public static Long LONG(String s){ return Long.parseLong(s); } //===================================================================================================================...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
99cae77ae257940dd9af13dfbb11ff8a
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int tc = sc.nextInt();...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
41775eae127dbe9cdc3fb28fb035189d
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; public class CF1185E { static final int A = 26; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int[] i1 = new int[A]; int[] i2 = new int[A...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
e21a44f35d4d72777d70287d8cafdb4f
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringJoiner; import java.util.StringTokenizer; public class MainE { public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int T = sc.nextInt(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
b645d9ad46654a21994e0290eb703fea
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; import java.lang.Math.*; public class EPolycarpandSnakes { static HashSet done = new HashSet(); static int []mark = new int[26]; public static void main(String[] args) { InputStream inputStream ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
3620fe8cd64914a35de96e7e79418163
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class zz{ public static void main(String[] args) throws IOException{ MScanner sc = new MScanner(System.in); PrintWriter pw...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
08e11ea688a88acc78302b49988332c6
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; /******************************\ * The solution is at the top * * * * Created by : azhar556 * \******************************/ public class B { static class Pair { int a, b; Pair (int a, int b) { this.a = a; this.b = b; } } static...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
2c9711c6e40f35df109ccd73a14ed6f2
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
//package cf568d2; import java.util.*; public class E { public static void main(String[]args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int w=0;w<t;w++){ boolean[]cont=new boolean[26]; boolean ok=true; int n=sc.nextInt(),m=sc.nextInt(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
47fa9243d6792941b4c44ecf9b821e6e
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; public class A { static char [][]comp; static void draw(int []x,int alpha) { int i1=x[0],j1=x[1],i2=x[2],j2=x[3]; for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) comp[i][j]=(char)('a'+alpha); } static int ALPHA=26; public static void main(String[] args) throws IOE...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
adcb3428134e265eb72a66d2070ae6e9
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; public class PolycarpAndSnakes { public static void main(String[] args) throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int t = Integer.p...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
731cb8aac8f50d3611d2e0e7691da0ff
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class l { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
3e6500effbf26994880de5b2e76a62bf
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
3dbede8c43bb9544cec6380825e5fab3
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; import java.util.Random; import j...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
7a0153efb0564f20ea7d8f0666a07919
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWri...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
db2987b52e8ca62b640650c47f338d31
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
69037591f67a56b62265aae33109c55e
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
51e7b0a9dd99b91c95d13cac0be04869
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.math.BigInteger; import java.nio.charset.Charset; import java.util.*; public class CFContest { public static void main(String[] args) throws Exception { boolean local = System....
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
13f45cea081de5419398dbb3950f8c01
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; import java.util.regex.*; public class Program { private static PrintWriter out; private static <T> void mprintln(T ... ar){ for(T i: ar) out.print(i + " "); out.println(); } ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
3e8a726decb0d859a4a87d6e4847d9c9
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.Objects; import java.nio.charset.C...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
87f0ac70c049b57506a1d83aa202c545
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Stream; /** * @author madi.sagimbekov */ public class C118...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
44dc63c38173cb5cc85b4d85235653f4
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; public class TaskE { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamRead...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
d4972b4ef6ffb836d36eb35627590681
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner in =new Scanner(System.in); int t= in.nextInt(); outer: while(t-->0){ int n =in.nextInt(); int m = in.nextInt(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
d10597bc809f45781649abe1abb2e64f
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; public class D{ public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); for(int q=0;q<t;q++){ ans = new ArrayList<>(); ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
594a9acdac75e0bea6417fa368f27763
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.Scanner; public class Main { private static boolean color(int x1 , int y1 , int x2 , int y2 , char ch) { for (int i = x1;i <= x2;i ++) { for (int j = y1;j <= y2;j ++) { if (matrix[i][j] == '*' || matrix[i][j] == ch) { continue; } else { return false; } } }...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
e8180c2da232578d39d5d09660b7d0d3
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; import static java.util.Arrays.sort; import static java.util.Comparator.comparingLong; public class Main { FastScanner in; PrintWriter out; private void solve() throws IOException { int n = ...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
2111059fc36bda60e501b86c05615913
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Rough { static Scanner sc = new Scanner(System.in); static StringBuilder sb = new StringBuilder(); static PrintWriter pw = new PrintWriter(System.out, true); public static void main(String[] args) { //code goes h...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
7a4507868841943f9d8114f3d8da1f11
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.util.*; import java.io.*; public class MainClass { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); StringBuilder stringBuilder = new StringBuilder();...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
882766f1f0ea652fc13f246b1378a669
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.BigInteger; import java.util.regex.*; public class Myclass { static char s[][]; static int n,m; static int start=0; static int end=0; static int cheak_row(int r,int c,char a) { int cnt=0; for(int i=r;...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
b8397c3720c6f315c8cfff7c78e970e2
train_001.jsonl
1560955500
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $$$n \times m$$$ (where $$$n$$$ is the number of rows, $$$m$$$ is the number of columns) and starts to draw snakes in cells.Polycarp draws snakes with lowe...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package coding; import java.util.*; /** * * @author Dell */ public class cdfrce1 { /** * */ public static cha...
Java
["1\n5 6\n...a..\n..bbb.\n...a..\n.cccc.\n...a..", "3\n3 3\n...\n...\n...\n4 4\n..c.\nadda\nbbcb\n....\n3 5\n..b..\naaaaa\n..b..", "2\n3 3\n...\n.a.\n...\n2 2\nbb\ncc"]
4 seconds
["YES\n3\n1 4 5 4\n2 3 2 5\n4 2 4 5", "YES\n0\nYES\n4\n2 1 2 4\n3 1 3 4\n1 3 3 3\n2 2 2 3\nNO", "YES\n1\n2 2 2 2\nYES\n3\n1 1 1 2\n1 1 1 2\n2 1 2 2"]
null
Java 8
standard input
[ "implementation", "brute force" ]
f34d21b9568c758cacc1d00af1316c86
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) β€” the number of test cases to solve. Then $$$t$$$ test cases follow. The first line of the test case description contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 2000$$$)Β β€” length and width of the checkered sheet of paper respecti...
2,000
Print the answer for each test case in the input. In the first line of the output for a test case print YES if it is possible to draw snakes, so that you can get a sheet of paper from the input. If it is impossible, print NO. If the answer to this question is positive, then print the way to draw snakes in the following...
standard output
PASSED
9bbd150b8cac63c0396d4bff7f762678
train_001.jsonl
1438273200
Teachers of one programming summer school decided to make a surprise for the students by giving them names in the style of the "Hobbit" movie. Each student must get a pseudonym maximally similar to his own name. The pseudonym must be a name of some character of the popular saga and now the teachers are busy matching ps...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.NoSuchElementException; import java.util.StringTokenizer; public class Cod...
Java
["5\ngennady\ngalya\nboris\nbill\ntoshik\nbilbo\ntorin\ngendalf\nsmaug\ngaladriel"]
2 seconds
["11\n4 1\n2 5\n1 3\n5 2\n3 4"]
NoteThe first test from the statement the match looks as follows: bill  →  bilbo (lcp = 3) galya  →  galadriel (lcp = 3) gennady  →  gendalf (lcp = 3) toshik  →  torin (lcp = 2) boris  →  smaug (lcp = 0)
Java 8
standard input
[ "dfs and similar", "trees", "strings" ]
c151fe26b4152474c78fd71c7ab49c88
The first line contains number n (1 ≀ n ≀ 100 000) β€” the number of students in the summer school. Next n lines contain the name of the students. Each name is a non-empty word consisting of lowercase English letters. Some names can be repeating. The last n lines contain the given pseudonyms. Each pseudonym is a non-empt...
2,300
In the first line print the maximum possible quality of matching pseudonyms to students. In the next n lines describe the optimal matching. Each line must have the form a b (1 ≀ a, b ≀ n), that means that the student who was number a in the input, must match to the pseudonym number b in the input. The matching should b...
standard output