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
a518c8064ce790c2193a4a3480936b64
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; import java.util.LinkedList; public class EGlobalRound4 { public static void main(String[] args) { FastScanner in = new FastScanner(System.in); String g = in.next(); int N = g.length(); int[] arr = new int[N]; f...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
22b4e20a780ba30caa886bd5878a7bab
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.math.*; // **** E. Archaeology **** public class E { static char [] in = new char [1000001]; public static void main (String [] arg) throws Throwable { char [] s = next().toCharArray(); int [] freq = new int [256]; for (int i =0;i <s.length;++i) freq[s[i]]++; char pivot = 'a'...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
791ff0e031f2743a39c21e8e5da4c19b
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
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
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
ec03dea1636c94a8b0cd8ad8ecd3e36f
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Random; import java.util.StringTokenizer; import java.util.TreeMap; publi...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
0fad3b889efe40ebb929113ffb277bba
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.io.*; public class codeforces{ // Input static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader() { reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = nul...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
79bd3f22944bdaaf0c393d4379fa2004
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Queue; import java.util.StringTokenizer; public class Archaeology { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTok...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
3a12683fe9efc6a4031f4257440dbdf6
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); String ans1 = oneLetterCenter(s, s.length() / 2); String ans2 = oneLetterCenter(s, s.length() / 2 - 1); if (ans1.le...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
69b096e8a11049f78d7b491d0b1231e6
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class Main2 { static long mod = 998244353; static FastScanner scanner; public static void main(String[] args)...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
ab8a56c9361501766b46703b8f103841
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.io.*; public class E { public static void main(String[] args) { Scanner f = new Scanner(System.in); String s = f.nextLine(); int n = s.length(); boolean[] out = new boolean[n]; for (int i = 0; i+1 < n-2-i; i+=2) { int[] cnt = new i...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
76ce969d4129ad1fe9b92522c55eadb5
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.util.*; public class A { BufferedReader in; StringTokenizer st; PrintWriter out; String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine()); return st.nextToken(); } int nextInt() throws Exception { return Int...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
7a2160eaaca0bbf96a47efc169382501
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
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
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
a6fbaf4f91f3edbf6f3832367d00a4d9
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.SortedSet; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; impo...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
47d2d222339b77e0bd9c945eb55a3c21
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.util.LinkedList; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); char[] s = sc.next()...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
3fbce4425182fc98b7e6f81dfba633cc
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class E { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); ...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
05b60aecbf7d219097e4ba4fdd7df5ff
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
// Don't place your source in a package import java.util.*; import java.lang.*; import java.io.*; import java.math.*; // Please name your class Main public class Main { //static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); /*static int read() throw...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
312e3dc460d6dca82e6c0a54be0530b2
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
/* * @author derrick20 */ import java.io.*; import java.util.*; public class archaeology { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); String s = sc.next(); char[] arr = s.toCharArr...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
e57f0e6e63335f9d2da15207b8853910
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class E { static BufferedReader br; static StringTokenizer st; private static ArrayList<Integer>[] graf; static ...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
2d5c6b91fe6e3724f95823ded9ffe92d
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; public class Main implements Runnable { static final int MOD = (int) 1e9 + 7; static final int M...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
78de4ae5e1e87d3700e8d506802ac612
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P33B { final static int SUB_ADD = 'a'; final static int SIZE = 'z' - SUB_ADD + 1; final static int MAX = Integer.MAX_VALUE >> 2; public void run() throws Exception { String s =...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
5932d87610e8ff9422c7e9204bcd1641
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.BigInteger; public class Main { public static String line; BigInteger x; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String []my ; int t,n,ca,i,...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
9720ad950131073a5c02f7734ee4d2ce
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { private static final int INF = 10000; static class FastReader { BufferedReader bufferedReader; S...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
701fd85d66844786be13040d4fde8dce
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import javafx.util.Pair; import java.util.Vector; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; impo...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
7233a1f2a8f812dc919c0409fc3f1f43
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; public class B33 { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); String s = input.next(), t = input.next(); int[][] cs = new int[26][26]; for(int[] A : cs) Arrays.fill(A, 10000001); for(int i ...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
275cfebbd23af8b10b3942cabcb081da
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
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.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; ...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
0ffe54e954a30721c3f051cc7d2424d6
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.Scanner; public class _33B { final static int N = 26; Scanner scanner = new Scanner(System.in); String source, destination; long m, totalCost=0; long[][] distance = new long[N][N]; public static void main(String[] args) { _33B solution = new _33B(); solution....
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
540f63d0623ea94c1a24e69f09fc7b89
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.*; import java.io.*; public class CF33B_StringProblem { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); if (a.length() != b.length()) { System.out.println(-1); return; } int n = sc.nextInt()...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
2f41ff7f8ade294fcf3f6840da13ed91
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
/* / フフ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム / )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ Y (⠀⠀| ( ͡° ͜ʖ ͡°)⠀⌒(⠀ ノ (⠀ ノ⌒ Y ⌒ヽ-く __/ | _⠀。ノ| ノ。 |/ (⠀ー '_人`ー ノ ⠀|\  ̄ _人'彡ノ ⠀ )\⠀⠀ 。⠀⠀ / ⠀⠀(\⠀ #⠀ / ⠀/⠀⠀⠀/ὣ====================D- /⠀⠀⠀/⠀ \ \⠀⠀\ ( (⠀)⠀⠀⠀⠀ ) ).⠀) (⠀⠀)⠀⠀⠀⠀⠀( | / |⠀ /⠀⠀⠀⠀⠀⠀ | / [_] ⠀⠀⠀⠀⠀[___] */ // Main Code at th...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
b36f7dda71f33a7a43166ae0f4de9a7f
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; /** * Created by Egor on 20/10/14. */ public class Task33B { BufferedReader reader; StringTokenizer tokenizer; PrintWriter w...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
6bfd234b60e91084d9def41d35317c61
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; public class Main { static final long INF = (long) 1e18; // don't increase, avoid overflow static class Edge implements Comparable<Edge> { int u; double cost; Edge(int a,double c) { u = a; cost=c; } public int compareTo(Edge e) { return Double.compare...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
f52b4c581cc572d79d2afea9cd152e24
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
/******************************************************************* My love has gone away, quietly after a hundered days. This is what's she has always said she won't stay for more than what she can repay. I can still hear her say there that I'm not hearing tender play The day she let me kiss her was a display, of lo...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
9546daa7873328ce36a51ead5616085d
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
d830250c22e46cf0a5885aa42ed2680a
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastReader fs = new FastReader(); String line1 = fs.nextLine()...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
6ce1b86fcc39ad417ea8f0d8601623a8
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; public class CodeForces { public static void main(String[] args) { FastIO io = new FastIO(); String first = io.nextLine(); String second = io.nextLine()...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
c5ea9cfc6d02b74f1f3e930f22dba723
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.*; public class StringProblem { static class Pair implements Comparable<Pair> { char letter; int cost; Pair(char letter, int cost) { this.letter = letter; this.cost = cost; } public int compareTo(Pair other) { return Int...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
4a31cef2ac548bc05626f8969da1a60d
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.StringTokenizer; import static java.lang.Math.min; /** * 33B * * @author artyom */ public class StringProblem implements Runnable { private BufferedReader in; private P...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
ee7bb7a5b01a795a04442c5b8d653ea1
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (nu...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
9cc9e48025385547f19a539f6f6f66f7
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.util.*; import java.io.*; public class B33 { public static void main(String[] args) throws IOException { PrintWriter w = new PrintWriter(System.out); InputReader in = new InputReader(System.in); String a = in.nextString(); String b = in.nextString(); int n = in.n...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
9c5e28375cff95dd8090a3a294850610
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
/** * Created by Alex on 10/20/2014. */ import java.io.*; import java.util.*; public class B33 { BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !in.hasMoreTokens()) { in = new StringTokenizer(br.readLin...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
d1165d5e99829ad1cab51cbe8dd90c46
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; public class Main { static int value[][] = new int[27][27]; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder s1 = new StringBuilder(br.readLine()); StringBuilder s2 = new StringBuilder(br.readL...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
eb37be6e85e44e72ea201c21fe4fb200
train_002.jsonl
1286463600
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can change one arbitrary ch...
256 megabytes
import java.io.*; import java.util.*; public class B33 { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); String s = input.next(), t = input.next(); int[][] cs = new int[26][26]; for(int[] A : cs) Arrays.fill(A, 10000001); for(int i ...
Java
["uayd\nuxxd\n3\na x 8\nx y 13\nd c 3", "a\nb\n3\na b 2\na b 3\nb a 5", "abc\nab\n6\na b 4\na b 7\nb a 8\nc b 11\nc a 3\na c 0"]
2 seconds
["21\nuxyd", "2\nb", "-1"]
null
Java 8
standard input
[ "shortest paths" ]
88c82ada2e66429900caeac758f7083b
The first input line contains two initial non-empty strings s and t, consisting of lower case Latin letters. The length of each string doesn't exceed 105. The following line contains integer n (0 ≤ n ≤ 500) — amount of possible changings. Then follow n lines, each containing characters Ai and Bi (lower case Latin lette...
1,800
If the answer exists, output the answer to the problem, and the resulting string. Otherwise output -1 in the only line. If the answer is not unique, output any.
standard output
PASSED
a04800ee843d9c2afbf74aedde15cfe4
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.util.*; public class maximus { public static void main(String [] args){ Scanner in=new Scanner(System.in); int array[]={1869,1968,1689,6198,1698,1986,1896,1869}; String str=in.next(); int temp[]=new int[10]; temp[1]=temp[6]=temp[8]=temp[9]=-1; for(int i=0;i<str.length();i++)temp[str.charAt(i)-'0']++; int mo...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
54b79298c636557e97e8b1adc56b7130
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.io.*; import java.util.*; public class a { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); String s = input.next(); int[] freq = new int[10]; for(int i = 0; i<s.length(); i++) freq[s.charAt(i) - '0']++...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
5becb03f690fbfbb9ccebc278df25edc
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class A { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanner(){ br=new BufferedReader(new InputStreamReader(Syst...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
27c986ca632a98b9d756a1f8b18c6ef2
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String[] args) { new A().run(); } public void run() { InputReader reader = new InputReader(System.in); PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); ...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
613f580f97afaaa0a238681b13422020
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; impor...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
31d3fbb995b3de8aa1a15f9739c36719
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Writer; public class DivisibleBySeven { private stat...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
909030aee2ee78d266fadee977062320
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException { A solver = new A(); solver.solve(); } private void solve() throws IOException { FastScanner sc = new FastScanner(System.in); // sc = new FastScanner("1689"); /...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
de9c793e5d9ce0e54041f03a05dfa178
train_002.jsonl
1387893600
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting ...
256 megabytes
import java.util.Scanner; public class main { public static void main(String[] args) { DivisibleBySeven.run(); } } class DivisibleBySeven { private static String[] table; public static void run() { init_table (); String input = get_input(); String output = get_output(input); System.out.println(outp...
Java
["1689", "18906"]
1 second
["1869", "18690"]
null
Java 6
standard input
[ "number theory", "math" ]
3b10e984d7ca6d4071fd4e743394bb60
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
1,600
Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.
standard output
PASSED
5c2e7f3b51fd815488af04ec1e140139
train_002.jsonl
1304175600
Fox Ciel safely returned to her castle, but there was something wrong with the security system of the castle: sensors attached in the castle were covering her.Ciel is at point (1, 1) of the castle now, and wants to move to point (n, n), which is the position of her room. By one step, Ciel can move from point (x, y) to ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.regex.Matcher; public class SafetySystem implements Runnable { int[] a; int[] b; int x; int y; long[]...
Java
["5 25 2 4 1", "3 6 1 2 2", "3 5 1 2 2", "20 492 11 4 8"]
1 second
["RRUURURU", "URUR", "Impossible", "RRRRRRRRRRRRRRRRUUUUURUUUUURRUUUUUUUUU"]
NoteThe answers for the first sample and the second sample are shown on the picture: Here, a red point represents a point that contains a sensor.
Java 8
standard input
[ "math" ]
4e388935c4b08101411bd2040040937b
In the first line there are five integers n, t, a, b, c (2 ≤ n ≤ 2·105,  0 ≤ t ≤ 1014,  1 ≤ a ≤ n - c + 1,  1 ≤ b ≤ n - c + 1,  1 ≤ c ≤ n). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin stream (also you may use the %I64d specificator).
2,900
If Ciel's objective is possible, output in first line 2n - 2 characters that represent her feasible steps, where i-th character is R if i-th step is moving rightward, or U if moving upward. If there are several solution, output lexicographically first one. Character R is lexicographically earlier than the character U. ...
standard output
PASSED
6766cc187bfe44d0cf8282b50eac081e
train_002.jsonl
1304175600
Fox Ciel safely returned to her castle, but there was something wrong with the security system of the castle: sensors attached in the castle were covering her.Ciel is at point (1, 1) of the castle now, and wants to move to point (n, n), which is the position of her room. By one step, Ciel can move from point (x, y) to ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.regex.Matcher; public class SafetySystem implements Runnable { int[] a; int[]...
Java
["5 25 2 4 1", "3 6 1 2 2", "3 5 1 2 2", "20 492 11 4 8"]
1 second
["RRUURURU", "URUR", "Impossible", "RRRRRRRRRRRRRRRRUUUUURUUUUURRUUUUUUUUU"]
NoteThe answers for the first sample and the second sample are shown on the picture: Here, a red point represents a point that contains a sensor.
Java 6
standard input
[ "math" ]
4e388935c4b08101411bd2040040937b
In the first line there are five integers n, t, a, b, c (2 ≤ n ≤ 2·105,  0 ≤ t ≤ 1014,  1 ≤ a ≤ n - c + 1,  1 ≤ b ≤ n - c + 1,  1 ≤ c ≤ n). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin stream (also you may use the %I64d specificator).
2,900
If Ciel's objective is possible, output in first line 2n - 2 characters that represent her feasible steps, where i-th character is R if i-th step is moving rightward, or U if moving upward. If there are several solution, output lexicographically first one. Character R is lexicographically earlier than the character U. ...
standard output
PASSED
b5d25e24c57a15cd98a0559f4ae0766b
train_002.jsonl
1304175600
Fox Ciel safely returned to her castle, but there was something wrong with the security system of the castle: sensors attached in the castle were covering her.Ciel is at point (1, 1) of the castle now, and wants to move to point (n, n), which is the position of her room. By one step, Ciel can move from point (x, y) to ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.regex.Matcher; public class SafetySystem implements Runnable { int[] a; int[] b; int x; int y; long[]...
Java
["5 25 2 4 1", "3 6 1 2 2", "3 5 1 2 2", "20 492 11 4 8"]
1 second
["RRUURURU", "URUR", "Impossible", "RRRRRRRRRRRRRRRRUUUUURUUUUURRUUUUUUUUU"]
NoteThe answers for the first sample and the second sample are shown on the picture: Here, a red point represents a point that contains a sensor.
Java 6
standard input
[ "math" ]
4e388935c4b08101411bd2040040937b
In the first line there are five integers n, t, a, b, c (2 ≤ n ≤ 2·105,  0 ≤ t ≤ 1014,  1 ≤ a ≤ n - c + 1,  1 ≤ b ≤ n - c + 1,  1 ≤ c ≤ n). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin stream (also you may use the %I64d specificator).
2,900
If Ciel's objective is possible, output in first line 2n - 2 characters that represent her feasible steps, where i-th character is R if i-th step is moving rightward, or U if moving upward. If there are several solution, output lexicographically first one. Character R is lexicographically earlier than the character U. ...
standard output
PASSED
d96d6e362d28eb4434bd75cca10903fc
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.*; import javax.swing.text.InternationalFormatter; import java.math.*; import org.omg.CORBA.Any; public class template { static long time = 0, mp = Integer.MAX_VALUE, k = 0, cn...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
52f904e94a9f3303f9077a3af45172ed
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int ans = 0; Set<Integer> visited = new HashSet<Integer>(); HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); HashMap<Integer,HashSet<Integer>> hash ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
3ac550e45ae857511140b8280cb5a499
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
/* Some say the world will end in fire, Some say in ice. From what I've tasted of desire I hold with those who favor fire. But if it had to perish twice, I think I know enough of hate To say that for destruction ice Is also great And would suffice. */ import java.io.*; import java.util.*; public final class Main{ ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
964b16faab617ba50812c40143dc4101
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.util.*; public class Main{ public static void main(String [] args) { Scanner scan = new Scanner(System.in); int n= scan.nextInt(); int a[] = new int[n+1]; for(int i=1;i<=n;i++) { a[i]=scan.nextInt(); } int max =0; ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
9da32ec197ef96e63f6918c650fa3df9
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.util.*; public class Party { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] managers = new int[n]; for(int i = 0; i < n; i++) { managers[i] = scanner.nextInt(); } int maxCount = 0; for(int i = 0; i < n; i++) { ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
b92e6ad06e857f81bea2a16d0820ed81
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Vector; import java.util.Scanner; import java.util.Stack; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @aut...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
e0e02400286110a8d5161b462c68d467
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static int level(int [] p,int i) { int l = 1; int manager = p[i]; while(manager != -1) { manager = p[manager-1]; l++; }...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
0c34e754d09bcbb7f72b7456734b3267
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.*; public class CF116C { static int level(int[] kk, int[] pp, int i) { if (kk[i] > 0) return kk[i]; return kk[i] = 1 + (pp[i] < 0 ? 0 : level(kk, pp, pp[i])); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
8ee4781b1646ca3e7db1b3313882a1c4
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.math.*; import java.util.StringTokenizer; /** * * @author T4reQ */ public class Codeforces { static int[] parent; static boolean[] seen; static in...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
5cfdafa50551aa5f7eb5db19aa755c5e
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
// Nailed it :) import java.io.*; import java.util.*; import java.awt.*; public class C { StringTokenizer st; BufferedReader in; PrintWriter ob; boolean visited[]; int val; public static void main(String args[])throws IOException { new C().run(); } void run()throws IOException { in=new BufferedReader(new ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
fe3f2cdd66c05bae718fd747155f1215
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.HashMap; import java.util.Map; import java.util.Scanner; /** * * @author gilad */ public class Party { p...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
14010ffd1aa9197e501848aeea5186bc
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { final static long mod = 1000000007; public static void main(String[] args) throws Exception { STDIN scan = new STDIN(); PrintWriter pw ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
afdd64121ca0e9f20977c24128e112b1
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
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.util.ArrayList; import java.util.StringTokenizer; public class CF116C { static ArrayList<Integer>[]...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
45d5d96161940dd22e8f22b436a15236
train_002.jsonl
1316098800
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager o...
256 megabytes
import java.util.*; import java.io.*; public class party { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int numpeople=sc.nextInt(); GraphAdjacencyList adjlist=new GraphAdjacencyList(numpeople); for(int i=1;i<=numpeople;i++) { int temp=sc.nextInt(); if(temp==-1) { ...
Java
["5\n-1\n1\n2\n1\n-1"]
3 seconds
["3"]
NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5
Java 8
standard input
[ "dfs and similar", "trees", "graphs" ]
8d911f79dde31f2c6f62e73b925e6996
The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employ...
900
Print a single integer denoting the minimum number of groups that will be formed in the party.
standard output
PASSED
36832fa7e56173693f13d17c7c25e3f0
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; 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.HashSet; i...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
67c29266bee773fe28491c6092c3d0d9
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; /** * Built using CHel...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
988aaad7403eeae20b82f4de5972a553
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int mod=998244353; static int pairs(int d) { return d+1; } static int pairs(int d1,int d2) { if(d1==0)return 0; int x=d1*10+d2; int lower=x-9; return Math.max(0, 9-lower+1); } static class segmentTree{ long[]dpLR,dpLr,dplR,dplr;//capital ...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
ebf576fae8b6aa8f3137d1b4f91c1562
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.*; import java.util.*; public class Main extends PrintWriter { void pre() { dp = new long[Math.max(n, 2)+1][10]; for(int d = 0; d < 10; d++) { dp[1][d] = (d+1); dp[2][d] = (d+1)*2L + (10-(d+1))*1L; } for(int i = 3; i <= n; i++) { ...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
e3dadbd3e720b73d7819d7e972f4643c
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.util.*; import java.io.*; public class F { public static long MOD = 998244353; public static long[] inv; public static void main(String[] args) throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new Outp...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
c9190736b5cb6915fe1a3f8b5f2e04e6
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; i...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
61077b259b45c61dd0539f5df2d0aaf7
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; i...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
18483eca85a713cdb897abfb3bf76295
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.function.IntBinaryOperator; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.Stri...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
7ed168184007e76930c9bdac46f6fe6f
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream;...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
5b11bc8dde45fe02be664a4e29de5458
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; import java.util.functio...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
c619430a0123c1a70255abd9e9477820
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; i...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
a88f190c4ca3c38dd514c0c6545433e8
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 998244353L; public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int N = sc.ni(); int Q = sc.ni(); String s = sc.next(); int[] nu...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
54785d81d4f0386384e8a93726f53227
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fcking inter...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
157042bfe35b633eac2c693a98782b30
train_002.jsonl
1594565100
Let $$$a$$$ and $$$b$$$ be some non-negative integers. Let's define strange addition of $$$a$$$ and $$$b$$$ as following: write down the numbers one under another and align them by their least significant digit; add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["2 3\n14\n2 4\n2 1\n1 0"]
5 seconds
["15\n12\n2"]
NoteAfter the first update $$$c$$$ is equal to $$$14$$$. The pairs that sum up to $$$14$$$ are: $$$(0, 14)$$$, $$$(1, 13)$$$, $$$(2, 12)$$$, $$$(3, 11)$$$, $$$(4, 10)$$$, $$$(5, 9)$$$, $$$(6, 8)$$$, $$$(7, 7)$$$, $$$(8, 6)$$$, $$$(9, 5)$$$, $$$(10, 4)$$$, $$$(11, 3)$$$, $$$(12, 2)$$$, $$$(13, 1)$$$, $$$(14, 0)$$$.After...
Java 8
standard input
[ "dp", "data structures", "matrices" ]
d3baf23c53ba50a03f5ef63d58d177cb
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^5$$$) — the length of the number $$$c$$$ and the number of updates. The second line contains a string $$$c$$$, consisting of exactly $$$n$$$ digits from $$$0$$$ to $$$9$$$. Each of the next $$$m$$$ lines contains two integers $$$x$$$...
2,600
Print $$$m$$$ integers — the $$$i$$$-th value should be equal to the number of pairs $$$(a, b)$$$ such that both $$$a$$$ and $$$b$$$ are non-negative integers and the result of a strange addition of $$$a$$$ and $$$b$$$ is equal to $$$c$$$ after $$$i$$$ updates are applied. Note that the numbers of pairs can be quite la...
standard output
PASSED
d95c039182a795db3f12b9796063e753
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(); char[] s = in.next().toCharArray(); final int mod = (int) 1e9 + 7; int[][] dp = new int[26][n + 1]; int[] sum = new int[n + 1]; sum[0] = 1; for (int i = 0; i < n; i++) { int...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
a8aa36ac60c55bc7fdd078be41b738ea
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.Arrays; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; impo...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
ab61d1ba9f39e25e774242ff43d4b9e3
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.Arrays; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; impo...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
2c083844f4337859930417bdd6bcd87e
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
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
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
95d80d3964621979c2113b256140a763
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.util.*; public class Test { static final int N = 5120; static final int L = 26; static final long M = 1000000007; long[][] dp = new long[N][32]; int[][] prefix = new int[N][32]; int[] idx = new int[32]; int n; Scanner sca = new Scanner(System.in); void start() { ...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
36a770bd2837909f38c386d49322e804
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.util.*; public class Test { static final int N = 5120; static final int L = 26; static final long M = 1000000007; long[][] dp = new long[N][32]; long[] prefix = new long[N]; long[] sum = new long[N]; int[] last = new int[26]; int n; Scanner sca = new Scanner(System.in)...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
aa3c27e90440a4faf2df5cf56779a373
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.util.*; public class Test { static final int N = 5120; static final int L = 26; static final long M = 1000000007; long[] ps = new long[N], sum = new long[N]; int[] last = new int[32]; int n; Scanner sca = new Scanner(System.in); void start() { n = sca.nextInt(); ...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
6f209227fde2a29fce3ad05e4c3e6a59
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
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
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
55ed38568c94dcdeb8726db9f9fec722
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.*; import java.util.*; public class ProblemC { static int MOD = 1000000007; public static void main(String[] args) { // TODO Auto-generated method stub FastScanner input = new FastScanner(); int n = input.nextInt(); String in = input.next(); ArrayList<Character> charList = new ArrayList<Cha...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
a0a9d8947209797fd87670d172ee3da2
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; import static java.util.Arrays.fill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStrea...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
635c387388fb14b1b42914336ce5a686
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter out; static Reader in; public static void main(String[] args) throws IOException { //out = new PrintWriter(new File("out.txt")); //PrintWriter out = new PrintWriter(System.out); //in = ...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
73798d112ce7615eeda185be43149f87
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.util.*; import java.io.*; public class D { int MOD = 1_000_000_007; void solve() { int initN = in.nextInt(); String s = in.nextToken(); String t = ""; for (int i = 0; i < s.length(); i++) { if (i == 0 || s.charAt(i) != s.charAt(i - 1)) { t += s.charAt(i); } } s = t; int n = s.l...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
ffd966f2779275ce1185adeafb047ae3
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
//package eightvc.f; 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 D2 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int mod = 1000000...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
c243dc0d6a39b194f9674e7b292e3a86
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
a730c26d3615594041fd375fc02b9cfe
train_002.jsonl
1485108900
Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters "a", ..., "z".The testtube is divided into n consecutive regi...
256 megabytes
import java.io.*; import java.util.*; public class D { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void test(int n) { char from = 'a'; char to = (char) (from + n - 1); StringBuilder sb = new StringBuilder(); for (char c = from; c <= to; c++) { sb.append(c); } String s =...
Java
["3\naaa", "2\nab", "4\nbabb", "7\nabacaba"]
2 seconds
["1", "3", "11", "589"]
NoteIn the first sample the population can never change since all bacteria are of the same type.In the second sample three configurations are possible: "ab" (no attacks), "aa" (the first colony conquers the second colony), and "bb" (the second colony conquers the first colony).To get the answer for the third sample, no...
Java 8
standard input
[ "dp", "combinatorics", "string suffix structures", "brute force" ]
81ad3bb3d58a33016221d60a601790d4
The first line contains an integer n — the number of regions in the testtube (1 ≤ n ≤ 5 000). The second line contains n small Latin letters that describe the initial population of the testtube.
2,400
Print one number — the answer to the problem modulo 109 + 7.
standard output
PASSED
f53749dd94452c313b6337520d199fd0
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputS...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output
PASSED
68af32c8d6e040e8f81a796b338bb0af
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class D { private static FastReader fr; private static OutputStream out; private static int mod = (int)(1e9+7); public static long[] red, green, blue; public static long dp[][][]; private void solve() { int r = fr.nextInt(); int g = fr.nextIn...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output
PASSED
ceba52c28fa0d4ad613f866a6a5edff3
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
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.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.i...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output
PASSED
d657ec18fe975df77367ad7ea5c069a9
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static int[][][] memo; static int[] red, green, blue; static int dp(int r, int g, int b) { if(r + g == 0 || g + b == 0 || r + b == 0) return 0; if(me...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output
PASSED
41d3856330851ff8be4f83c0772ee343
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
256 megabytes
import java.io.*; import java.util.*; //import sun.tools.serialver.resources.serialver; public class Main { static long dp[][][]; static int nr,ng,nb; static int ar[],ag[],ab[]; public static long solve(int r,int g,int b) { if(dp[r][g][b]==-1) { long best=0; if(r<nr) best=Math.max(best, solve(r+1, g, ...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output
PASSED
42b5a679662e8ba4bdee3e91ffd7a241
train_002.jsonl
1597415700
You are given three multisets of pairs of colored sticks: $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$; $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_...
256 megabytes
// Submitted By Subhash Yadav import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Scanner; import java.util.*; ...
Java
["1 1 1\n3\n5\n4", "2 1 3\n9 5\n1\n2 8 5", "10 1 1\n11 7 20 15 19 14 2 4 13 14\n8\n11"]
2 seconds
["20", "99", "372"]
NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \ti...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9e6cb1e8037e1d35b6c6fe43f805a22f
The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of...
1,800
Print the maximum possible total area of the constructed rectangles.
standard output