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
8cedfdb66d391568ee37f8d0ca1a3184
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 < p_2 < \ldots < p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class maxWidth { public static void main(String[] args) { // Scanner sc = new Scanner(System.in); // int t = sc.nextInt(); // for(int o= 0 ; o<t;o++) { FastReader sc = new FastRead...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
af222047fb1c7e477103f76a83b851fc
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class D{ public static void main(String[] args) throws IOException { // br = new BufferedReader(new FileReader(".in")); // out = new PrintWriter(new FileWriter(".out")); //new Thread(null, new (), "peepee", 1<<28).start(); readInt(); readInt(); St...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
3032f472dcdfc53b2a165af57ac4ad0c
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class C70 { static BufferedReader br; static long mod = 1000000000 + 7; static HashSet<Integer> p = new HashSet<>(); public static void main(String[] args) throws Exception { br = new Buffer...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
bd707edb66d59b4e0a4a0e7f3273c21c
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class longetsdiffincommonsubseq { static class FastScanner { InputStreamReader is; BufferedReader br; StringTokenizer st; public FastScanner() { is = new InputStreamReader(System.in); br = new BufferedReader(is); } String next() throws Excepti...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
dbace44fcd81b53113fe0fa3def876f1
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) { // Scanner scan = new Scanner(System.in); FastScanner scan = new FastScanner(); int m = scan.nextInt(); int n = scan.nextInt(); char[] s = scan.n...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
b3be1f0d470a8deeb8b9974701cc6a91
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.System.out; public class C704 { public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); int n = Integer.p...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
75815a6c21e37146003793735ac0de1f
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.lang.*; import java.lang.reflect.Array; import java.util.*; import java.io.*; public class Main { static FastScanner in = new FastScanner(); static void solve() { int n = in.nextInt(), m = in.nextInt(); char[] s = in.nextLine().toCharArray(), t = in.nextLine().toCharArray...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
4e0a356c8a10133700cb77d389426d28
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; public class Prob_one { public static void main(String args[]) { Scanner sc =new Scanner(System.in); int a,b; a=sc.nextInt(); b=sc.nextInt(); String a1,a2; a1=sc.next(); a2=sc.next(); int min[]=new int[b]; int max[]=new int[b]; int l=-1; for(int i=0;i<b;i++) { char c =a2.charAt...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
e278a693d350d36c2ab5e1dd4bd1af31
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()thro...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
9b1eb3c10ca790798a00e1992a93d26b
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
//package clipse; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.*; import java.math.*; public class BB { static StringBuffer sb; static boolea...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
9b92a6a9a6176899b74127c0eab8f41b
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
//package credit; import java.io.*; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ static boolean v[]; static int ans[]; int size[]; static int count=0; static int...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
94e5869a00835be83917529f1b143ac5
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class C_Maximum_width { public static void main(String[] args) { FastScanner fs = new FastScanner(); int n = fs.nextInt(); ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
bda32f5b057bca164b878e2d22177015
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.StringTokenizer; import java.util.TreeSet; @SuppressWarnings("ConstantConditions") public fin...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
9b305fb55f5964f3c49038ef8e0dc74f
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.StringTokenizer; import java.util.TreeSet; public final class C { public static void ma...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
35b06c3aacc27bc92b8a261496aaa4d0
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class Main{ static int mod=(int)1e9+7; public static void main(String[] args) throws IOException { PrintWriter out=new PrintWriter(System.out); Reader in=new Reader(System.in); int ts=1; // ts=in.nextInt(); while(ts-->0) solve(in, out); out.clo...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
e2914283faf762152b81402807962acf
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelpe...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
63c0fe9329371964fd00c364fc528fac
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
//package random; import java.io.*; import java.util.*; public class Playoff { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
274bf094a0fa8fca1ccf117e4fe61efb
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.lang.Math; import java.util.*; import javax.management.ValueExp; public final class Codechef { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new BufferedWriter( new OutputStreamWriter(System.out) ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
5fd6122d9b3344d052cac3a93133305a
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.util.Map.Entry; import java.math.*; public class Simple{ public static class Pair{ int x; long y; public Pair(int x,long y){ this.x = x; this.y = y; } } static int power(int x, int ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
c6de0b65db2f267a379266dc3a54810a
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class C_Maximum_width{ static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
658cdc7bf9241678f6a0d73eabeb81be
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.HashMap; import java.util.Scanner; public class reversestring { private static class pair{ int low,high; pair(int low,int high){ this.low=low;this.high=high; } } public static void main(String[] args) { Scanner in = new Scanner(Syste...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
c37d1006d4424c6fa395eb14dd2dcab6
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class MaxWidth { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.n...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
e7e930d37b74c20b11eae499ac54a07f
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class MaximumWidth { public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader(...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
36a4b91eb2da21b6051f0b908f5623aa
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; public final class Solution{ public static void main (String[] args) throws Exception { BufferedWriter op = new BufferedWriter(new OutputStreamWriter(System.out)); Scanner sc= new Scanner(System.in); ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
b7655d24bc474ffae405933f87dcb435
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
/* _oo0oo_ o8888888o 88" . "88 (| -_- |) 0\ = /0 ___/`---'\___ .' \\| |// '. / \\||| : |||// \ / _||||| -:- |||||- \ ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
387ed6e8cd73c1bc8d76cd65128ded83
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class Main { static BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer tok; public static void main(String[] args) throws Exception { ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
5594cc1d37e1805c6c3095da542fbc0a
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class tank { static final FastScanner fs = new FastScanner(); public static void main(String[] args) { // int t = fs.nextInt(); // while(t-->0){ // run_case(); // } run_case(); } static void run...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
8a50d53baa08eacb780f31d3864437e1
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class CodeForces extends Functions { static Scanner sc = new Scanner(); public static void solve() { int n = sc.nextInt(); int m = sc.nextInt(); String s =sc.next();...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
b3a175e574e24dbb75dd63b4e43c4bcc
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class MaxWid { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] snm=br.readLine().split(" "); int n = Integer.parseInt(snm[0]); int m = Integer.parseInt(snm[1]);...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
5a65300bd15386168f9205dc71462244
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { Scanner scanner=new Scanner(System.in); int a=scanner.nextInt(); int b=scanner.nextInt(); String aa=scanner.next(); String ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
7471807a4a4817222d5b66d5a3f9f330
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
// package feb2021; import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class cf_subs { static FastReader scn = new FastReader(); static OutputStream out = new BufferedOutputStream(System.out); public static void main(String[] args) throws IOException { // TODO Auto-ge...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
1e64cc1afbfecc7517e6262facd7d01d
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class ProblemD { public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n=sc.nextInt(); int m=sc.nextInt(...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
f430a73f5bb34460da97b1009ae9dd05
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; public class Solve{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); char[] s=sc.next().toCharArray(); char[] t=sc.next().toCharArray(); ArrayList<Int...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
b9c32ace4a06f2bebcca7fa230e5b75c
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; import java.util.function.*; import static java.lang.Math.*; public class C{ public static void main(String[] args) throws Exception { InputStream inputStream; OutputStream outputStream; if(args.length > 0 && System.getProperty("ONLINE_JUDGE") ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
8a118fed56c4fc1495949f2b2e0eb446
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import javax.swing.plaf.FontUIResource; import java.lang.reflect.Array; import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main(String[] args) throws java.lang.Exception { out = new PrintWriter(new BufferedOutputStream(System.out)); sc = ne...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
2004a8e71186f35dfc05be7d90c52728
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private Spa...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
1e23e0e33a5cefb8d92daa4a27971d86
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.PrintWriter; import java.util.*; public class TP { public static PrintWriter out = new PrintWriter(System.out); public static Scanner in = new Scanner(System.in); public static void main(String[] args) { long s = System.currentTimeMillis(); int t = 1; // t...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
ff13b05330ee52073a36e190bcac4746
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); int m = sc.nextInt(); String s = sc.next(), t = sc.next(); Map<Character,List<Integer>> map = new HashMap<>(); for(int i = 0; i ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
aedf038653048aa8fb089a4d05bcc97f
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
//@author->.....future_me......// //..............Learning.........// /*Compete against yourself*/ import java.util.*; import java.io.*; import java.lang.*; import java.math.BigInteger; public class C { // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< // static F...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
1f18028ad9cb5e37bf7aaf3e8eb3f095
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class C2 { BufferedReader input; BufferedWriter output; StringTokenizer st; private static float binarySearch(ArrayList<Integer> arr, int start, int end, int x) { if (end >= start) { int mid = start + (end - start) / ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
9190b3b2dde97412291b174aae2a8e5a
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class P1492C { static InputReader in = new InputReader(System.in); static PrintWriter pw = new PrintWriter(System.out); static long mod = (long) (Math.pow(10, 9)) + 7; static HashMap<Integer, List<Integer>> adjList = new HashMap<>(); static boolean...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
e8fe72c1fea378897c0193e37f38cbd5
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner in=new FastScanner(); PrintWriter out=new PrintWriter(System.out); // int t=in.nextInt(); // while(t-->0) solve(in,out); out.close(); } ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
aca0779a301dc2f3b994a414ce5816d8
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
/*----------- ---------------* Author : Ryan Ranaut __Hope is a big word, never lose it__ ------------- --------------*/ import java.io.*; import java.util.*; public class Codeforces2 { static PrintWriter out ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
38ffd66d0ea59e5b87d21ec7f5723fc2
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codeforces { public static void main(String[] args) throws java.lang.Exception { /* your code goes here */ BufferedReader buf = new BufferedReader(n...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
5deec318846a0bc037b453fd089cde48
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
/* 5 3 abbbc abc */ import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer details = new StringTokenizer(br.readLine()); int n = Integ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
262d4f7c51ec624855c8b1327e5aeeeb
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class Main { static PrintWriter out; static Kioken sc; public static void main(String[] args) throws FileNotFoundException { boolean t = true; boolean f = false; if (f) { out = new PrintWriter("output.txt"); ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
78d904abaae53819b233be4d66ae9e65
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import com.sun.source.tree.LiteralTree; import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.lang.Math.ceil; import static java.util.Arrays.sort; public class C { static int mod = 1000000007; public static void main(String[] args) throws Exception { ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
cff56ebc42283486d7659f83547066f2
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Pupil { static FastReader sc = new FastReader(); public static void main (String[] args) throws java.lang.Exception { // your code...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
480c0e69e81892858dee8ea0a07522dd
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static int max ; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int n = sc.nextI...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
096a01ebb45f90b55e93a742779d6bc0
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.File; import java.io.*; import java.util.*; public class Main { // static final File ip = new File("input.txt"); // static final File op = new File("output.txt"); // static { // ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
fa869614231495d12453b2e77a278480
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; import java.util.InputMismatchException; public class Main { static PrintWriter out; static Reader in; public static void main(String[] args) throws IOException { input_output(); Main solver = new Main(); solver.solve(); out.clos...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
4dda84b0f764149a50570c95900c6018
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
// package codeforce.cf704; import java.io.PrintWriter; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
074f931539ccf133099281c48611edb7
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
2f796f308e7b04b19d5b1d25e744c4a7
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; public class copy { static long ans; public static long[] inv(long[] arr,int l,int r) { if(l>r) return null; if(l==r) { ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
bce2431333294d51a3e512f87dc5a8b4
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class new1 { public static int func(char[] s1, char[] s2, int[] first, int[] last, int i, int j) { if(i == s2.length - 1) { return 0; } ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
c2cb38ea2f0fb4d62e052486599b0e84
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.nextInt(); sc.nextInt(); String s = sc.next(); String t = sc.next(); System.out.println(solve(s, t)); sc.close(); } sta...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
9689d388b362649be630c20a60f71871
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
//package codeforces; import java.io.PrintWriter; import java.util.*; public class solution { public static void main(String args[]){ Scanner s=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int t=1; for(int tt=0;tt<t;tt++) { int n=s.nextInt(),m=s.nextInt(); String...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
7419c0b88e96e8eef66b29d764497f6b
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; public class Solution { // static boolean[][] isVisited; static int[][] dp; static Scanner sc = new Scanner(System.in); public static void main(String args[]) { // int t=sc.nextInt(); // while(t-->0){ int n=sc.nextInt(),m=sc.nextInt(); sc.nextLine(); ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
211ff70e9ec192c6ca97ce93fd7b420c
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class maximum_width { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer line = new StringTokenizer(in.readLine()); int n = Integer.parseInt(line.ne...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
5bd4ae67d005f8ee63d7eca4f03cc3a0
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class First { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
90a6849b192cdafcdad7fee632455849
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.ArrayList; import java.util.List; public class MaximumWidth { public static void main(String[] args) throws Exception { // BufferedReader br = new BufferedReader(new FileReader(new File("input.txt"))); BufferedReader br = new BufferedReader(new InputStreamReader(S...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
8246956ac0a9b59c5e36fc05137d6ba2
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; import java.io.File; // Import the File class import java.io.FileNotFoundException; // Import this class to handle errors import java.util.Scanner; public class Main { public static void main(String args[])throws Exception { BufferedReader bu=new ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
946c6959f12b1015550a3f59f559c1af
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.LinkedList; import java.util.StringTokenizer; public class Main { private static void run(Reader in, PrintWriter out) throws IOException { int n = in.nextInt(); int m = in.nextInt(); char[] s = in.next().toCharArray(); char[] t = in.next().toCharA...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
387f02b80d8e69c2e789ef45bb1d7cfb
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class MaximumWidth { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int test...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
f64486afc02fde2be1d038f74258e12b
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class CMaxWidth { public stat...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
062d918d430af2f9b89cf9dba905ba46
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.io.*; public class MaxWidth { private static class MyScanner { BufferedR...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
d73b5e91c266ba733c52f3765f7d5c17
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(); String s = sc.next(), t = sc.next(); int[] left = new int[n], right = new int[n]; int idx = 0; for (int i = 0; i < m; i++) { while ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
203d9086c44c76cdf4eef39d5aff0a76
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(String s) { try { br = new BufferedReader(new FileReader(s)); } catch (FileNotFoundEx...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
f47a762ebae0b4b95be6158a9c50256e
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; public class Random { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // int tc = sc.nextInt(); // while (tc-- > 0) { // } int n = sc.nextInt(); int m = sc.nextInt(); String s = sc.next(); ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
580bd2e67f94421bfabe4033bcdbe120
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class cc_march2020_long { public static void main(String[] args) { Scanner scn=new Scanner(System.in); int n=scn.nextInt(); int m=scn.nextInt(); scn.nextLine(); String s=scn.nextLine(); String t=scn.nextLine(); int[]low=new int[m]; int[]high=n...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
24474c748ea07f0fab3a3283c5fa32e1
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.util.*; import java.io.*; public class three { public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new BufferedReader(new FileReader("three")); int t = 1; wh...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
ba143bbd0d5c339e6314542d14943039
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
31a9a747da0fec55e51933fdd7227fbc
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.nio.file.Paths; import java.util.*; public class Main extends PrintWriter { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));Main () { super(Syste...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
4c77b4c787933b91bf56d1a442eb19fb
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
// Problem: C. Maximum width // Contest: Codeforces - Codeforces Round #704 (Div. 2) // URL: http://codeforces.com/contest/1492/problem/C // Memory Limit: 512 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) import java.io.*; import java.util.*; public class Main { ...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 11
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
e642c920f979386ab8f2f7a4d6602d7c
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. ***********************************************...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 17
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
42f5488ab7369e9c1904de9c4d582c57
train_109.jsonl
1614071100
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $$$s$$$ of length $$$n$$$ and $$$t$$$ of length $$$m$$$.A sequence $$$p_1, p_2, \ldots, p_m$$$, where $$$1 \leq p_1 &lt; p_2 &lt; \ldots &lt; p_m \leq n$$$, is called beautiful, if $$$s_{p_i} = t_i$$$ for...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /** * * @author eslam */ public class Solution { // Beginning of the solution static Kattio input = new Kattio(); static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); static ArrayList<Arra...
Java
["5 3\nabbbc\nabc", "5 2\naaaaa\naa", "5 5\nabcdf\nabcdf", "2 2\nab\nab"]
2 seconds
["3", "4", "1", "1"]
NoteIn the first example there are two beautiful sequences of width $$$3$$$: they are $$$\{1, 2, 5\}$$$ and $$$\{1, 4, 5\}$$$.In the second example the beautiful sequence with the maximum width is $$$\{1, 5\}$$$.In the third example there is exactly one beautiful sequence — it is $$$\{1, 2, 3, 4, 5\}$$$.In the fourth e...
Java 17
standard input
[ "binary search", "data structures", "dp", "greedy", "two pointers" ]
17fff01f943ad467ceca5dce5b962169
The first input line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq m \leq n \leq 2 \cdot 10^5$$$) — the lengths of the strings $$$s$$$ and $$$t$$$. The following line contains a single string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the Latin alphabet. The last line contains a single string ...
1,500
Output one integer — the maximum width of a beautiful sequence.
standard output
PASSED
acf1d2f97a9afa6edf03c9d37ec09968
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; public class CardDeck { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputSt...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
9b98aa24fbb982a3fed25deff5a0cd96
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class CardDeck { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
df3f381a2d27989f081e37d4719173f3
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; public class CodeForces704 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i<t; i++){ System.out.println(solve(sc)); } } static int[] dp; static Strin...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
0dc5daa74861772e890e7b8928db8aa3
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
// 23-Feb-2021 import java.util.*; import java.io.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; private FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElemen...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
e412c1b54a6e688f8573c76f99a387bc
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
// 23-Feb-2021 import java.util.*; import java.io.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; private FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElemen...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
c2ccac16544d485a1db79dc30e8ebc5b
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class contest704_B { public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader(System.in...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
1b3e7af56b5d54a3894750f20784bc21
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.Scanner; public class cf1492B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); int n = 0; int k = 0; int[] a,b; StringBuilder sb = new StringBuilder(); while(t-->0...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
6c796ecd8033ceaa84a87d919eef6e63
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { static List<Integer> list = new ArrayList<>(); static StringBuilder ans; static boolean[] V; static int mv; static Str...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
1e2ddb6f570849e91abb76a5509044bb
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
//package com.math; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.StringTokenizer; public class CardDeck { public void solve(){ FastScanner in = new FastScanner(System.in...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
b2dfd71d7bb67d3ba068a93eda6c7056
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.PriorityQueue; import java.util.Scanner; public class code { static int x[]; static int y[]=new int [100000000]; public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.ne...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
d7845390fc708366d96b40b269f28038
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; public class CardDeck0520 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int t1 = 1; t1 <= t; t1++){ int n = sc.nextInt(); int[] ar = new int[n+1]; int[] ind = new int[n+...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
8827dfa3f0ba881c6cdebd8c754f3ecd
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; public class Check2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { /* long p=sc.nextLong(); long a=sc.nextLong(); long b=sc.nextLong(); ...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
ce94ccbbc6db8e0e56b6ccbb02035d36
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Comparator; import java.util.HashMap; import java.util.Scanner; import java.util.Stack; public class Main { static class point { long val, time, t3; point(long val, long t...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
24a1bb070a32dc54b1b550d885bd1579
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; import java.util.HashMap; public class Q23__2 { public static void main(String []args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int i=0,s=0,e=n-1,k=0,p=n; boolean br=false; ...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
2d13129f91a4aba12f276ca3f223e6b0
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class F { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static PrintWrite...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
8dd09b194454c4558dcb6187daf0d491
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
/* "जय श्री कृष्णा" */ import java.util.*; import java.io.*; public class Deck_B implements Runnable { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
6c4dfc43d108436cede9ce538e6c17a1
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
/* "जय श्री कृष्णा" */ import java.util.*; import java.io.*; public class Deck_B implements Runnable { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
b04ecc2cdb49eb64e961b05bc0c1d8f5
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
/* "जय श्री कृष्णा" */ import java.util.*; import java.io.*; public class Deck_B implements Runnable { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
7a2d121f3817df971f66701dc94d8bc8
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 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 Main { /* Need to notice deck order is optimal when we move the greatest element as far to the left as we can */ ...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
5e8dd284fc2b02c728a612dac632470f
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; public class CardDeck { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tests = sc.nextInt(); sc.nextLine(); int[] A = new int[101010]; int[] pos = new int[101010]; while (tests > 0) { long stackSize =...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
1c149189da99027518201324adcc4156
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int[] indexOf = new int[n]; int[] arr = new int[n]; for(int i=0;i<n;i++) arr[i...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
035fc77b68d6452d8fbf8f1237d31423
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedList; import java.util.TreeSet; public class CardDeck { public static void solve(ArrayList<Integer> q,int max,int n) { // System.out.println(q); // System.out.pr...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
88975de93f087826f5c61c6d2032b752
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int i,j,k,l,m,n,t,p; t = Integer.parseIn...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output
PASSED
e33a9d3dd51c9080eea4d9dffb21d017
train_109.jsonl
1614071100
You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you ...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; //import jdk.javadoc.internal.doclets.toolkit.NestedClassWriter; public class Codeforces { static String a,b; static class Node { int val; Node left; Node right; public Node(int ...
Java
["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"]
1 second
["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"]
NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1...
Java 8
standard input
[ "data structures", "greedy", "math" ]
1637670255f8bd82a01e2ab20cdcc9aa
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$...
1,100
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.
standard output