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
345b6be30650cb560b1fc2ff3b9b09f2
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
/* stream Butter! eggyHide eggyVengeance I need U xiao rerun when */ import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class x1545A { public static void main(String hi[]) throws Exception { BufferedReade...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
dc286a39c8dafbd38ebe69147eee8f5a
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class AquaMoonAndStrangeSort { public static void main(String args[]) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); whil...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
631de58a9f7e0ba82ac911451744004b
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { //////////////////////////////////////////////////////////////////////////////////// // THE MERGE SORT IS TAKEN FROM GEEKSFORGEEKS// ///////////////////////////////////////////...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
1d6a1f6eb1af842bf45f6f527b54b75e
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { MyScanner scan = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); for (int i = scan.nextInt(); i > 0; i--) { int[] arr = new int[scan.nextI...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
d6c6b1954cc3e57d023e65bc66a3bec6
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /* Name of the class has to be "Main" only if the class is public. */ public class Coder { static int n; static int a[]; static StringBuilder str = new StringBuilder(""); static int cnt[][] = new int[(int)1e5+5][2]; static void solve() { ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
9005e8e0a138eaa7ef1ae5491f689604
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.io.*; public class cff { static int mod=1000000007; public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t-->0) { int n=s.nextInt(); ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
dbc39404a55c787dd859445428a06975
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class pcarp{ static int max_value; static long mod = (long)1e9+7; static long ans = (long)1e15; static int MAXN = (int)1e5; static...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
3b94efcb3e9bc530ce54ac0e0c356606
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.util.ArrayList; import java.util.Collections; import java.util.Map; import java.util.Scanner; import java.util.LinkedHashMap; import java.util.List; public class AquaMoon_and_Strange_Sort { public static void main(String[] args) { Scanner input = new Scanner(S...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
d3fc58b7f2b25f759db4b43ee0a274a7
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
//package codeforces; import java.io.*; import java.util.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElement...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
0faff4072fc46411e2ccbd72700bfe12
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc = 0; tc < t; ++tc) { int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
7d440a380c9a0d7018709c057384aa8b
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class A1545 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); for (int t=0; t<T; t++) { int N = in.ne...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
feb5217a545fbfce8feb047a10420a18
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.security.KeyStore.Entry; import java.util.*; public class Odd_Selection { static InputStreamReader r = new InputStreamReader(System.in); static BufferedReader br = new BufferedReader(r); static PrintWriter p = new PrintWriter(System.out);...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
505ee7356f392db445639e8f69c92dbe
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
0ebf285cc07a4ff7e4529fb2f2c54c5b
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class StrangeSort{ static long mod = 1000000007L; static MyScanner sc = new MyScanner(); static void solve() { int n = sc.nextInt(); HashMap<Integer,Pair> map = new HashMap<>(); int arr[] = new int[n]; for(int i = 0;i<n;...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
def0c07bf5ecfc8e2f662add2c43ba33
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static class Pair implements Comparable < Pair > { int d; int i; Pair(int d, int i) { this.d = d; this.i = i; } public int compareTo(Pair o) { return this.d -...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
0f6b8506f3107ea97d33b1de6dc12e2e
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int T = in.nextInt(); for(int ttt = 1; ttt <= T; ttt++) { int n = in.nextInt(); ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
376b3cadfe97b180e692905c2ac4de63
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import static java.lang.Math.*; import java.io.*; public class S { public static int surv = 0; public static void main(String args[])throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test = Integer.parseIn...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
234ab9417abf253b4244d80679f2f2a0
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class A1545 { public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); FastPrintStream out = new FastPrintStream(System.out); int t = sc.nextInt(); for (int tn = 0; tn < t; tn++) { int[]...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
0cfb900c19e118fedba2aee5cc1d5399
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
//import java.io.IOException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class AquaMoonandStrangeSort { static InputReader inputReader=new InputReader(System.in); static void solve() { ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
5981cbb825492facfddc1c97cecf7cb9
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class new1 { public static void main (String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); for(int i = 0; i < t; i++) { int n = s.nextInt(); ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
dc063d937849162fad3e48e597cbf226
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.io.PrintStream; //import java.util.*; public class Solution { public static fina...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
a5f8c0150ed7b99e171e0dc0065df264
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class CODECHEF { static class FastReader { byte[] buf = new byte[2048]; int index, total; InputStream in; FastReader(InputStream is) { in = is; } int scan() throws IOException { ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
d81db380634b973a3e9f9a283551e0d7
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static void main() throws Exception{ int n=sc.nextInt(); int[]in=sc.intArr(n); int[]even=new int[(n+1)>>1],odd=new int[n>>1]; for(int i=0,idx=0;i<n;i+=2,idx++) { even[idx]=in[i]; } for(int i=1,idx=0;i<n;i+=2,idx++) { odd[idx]=i...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
4d362b516e058c999a7e30e2ed414868
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public final class Solution { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)}; public static void main(Strin...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
ea327b70e3084b0cda006a32c862a2f9
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class AquamoonAndStrangeSort { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { int ...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
2cc478afbb9ec39941cd501c8e58f123
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Arrays; import java.util.Comparator; import java.util.Locale; import j...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
d86816ea86187594c2dc25fe4d708a26
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; boolean systemIO = true; public int add(int x, int y) { if (x + y >= mod) { return x + y - mod; } return x + y; } public int subtract(int x, int y) { if (x >= y) { return x - y; } return...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 8
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
1af984c3136a6b6f80eb3d1d5146470f
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 megabytes
import java.util.*; import java.util.Scanner; import java.lang.Math; public class JvForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int cs = 0; cs < t; cs++) { int n = sc.nextInt(); TreeMap<I...
Java
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 17
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
eda88054f1cea91fc10734efefba8971
train_108.jsonl
1626012300
AquaMoon has $$$n$$$ friends. They stand in a row from left to right, and the $$$i$$$-th friend from the left wears a T-shirt with a number $$$a_i$$$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.AquaMoon can make some operations on friends. On each ...
256 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
["3\n4\n4 3 2 5\n4\n3 3 2 2\n5\n1 2 3 5 4"]
1 second
["YES\nYES\nNO"]
NoteThe possible list of operations in the first test case: Swap $$$a_1$$$ and $$$a_2$$$. The resulting sequence is $$$3, 4, 2, 5$$$. The directions are: left, left, right, right. Swap $$$a_2$$$ and $$$a_3$$$. The resulting sequence is $$$3, 2, 4, 5$$$. The directions are: left, left, right, right. Swap $$$a_1$$$ an...
Java 17
standard input
[ "sortings" ]
1d27d6d736d891b03b7476f8a7209291
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of Aquamoon's friends. The second line contains $$$n$$$ integers $$$...
1,500
For each test case, if there exists a possible sequence of operations, print "YES" (without quotes); otherwise, print "NO" (without quotes). You can print each letter in any case (upper or lower).
standard output
PASSED
24a89a16fa6b8cd279fca8c0ec27ca5f
train_108.jsonl
1626012300
Cirno has prepared $$$n$$$ arrays of length $$$n$$$ each. Each array is a permutation of $$$n$$$ integers from $$$1$$$ to $$$n$$$. These arrays are special: for all $$$1 \leq i \leq n$$$, if we take the $$$i$$$-th element of each array and form another array of length $$$n$$$ with these elements, the resultant array is...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= 998244353; long fac[]= new long[1000001]; lon...
Java
["3\n7\n1 2 3 4 5 6 7\n2 3 4 5 6 7 1\n3 4 5 6 7 1 2\n4 5 6 7 1 2 3\n5 6 7 1 2 3 4\n6 7 1 2 3 4 5\n7 1 2 3 4 5 6\n1 2 3 4 5 7 6\n1 3 4 5 6 7 2\n1 4 5 6 7 3 2\n1 5 6 7 4 2 3\n1 6 7 5 2 3 4\n1 7 6 2 3 4 5\n1 7 2 3 4 5 6\n5\n4 5 1 2 3\n3 5 2 4 1\n1 2 3 4 5\n5 2 4 1 3\n3 4 5 1 2\n2 3 4 5 1\n1 3 5 2 4\n4 1 3 5 2\n2 4 1 3 5\n...
2 seconds
["1\n1 2 3 4 5 6 7\n2\n1 3 5 6 10\n4\n1 3 6 7 8 9"]
NoteIn the first test case, the number of good subsets is $$$1$$$. The only such subset is the set of arrays with indices $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$7$$$.In the second test case, the number of good subsets is $$$2$$$. They are $$$1$$$, $$$3$$$, $$$5$$$, $$$6$$$, $$$10$$$ or $$$2$$$, $$$4$$...
Java 8
standard input
[ "2-sat", "brute force", "combinatorics", "constructive algorithms", "graph matchings", "graphs" ]
e284f33d82824afb23042e9dab0956ad
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$5 \leq n \leq 500$$$). Then $$$2n$$$ lines followed. The $$$i$$$-th of these lines contains $$$n$$$ int...
2,800
For each test case print two lines. In the first line, print the number of good subsets by modulo $$$998\,244\,353$$$. In the second line, print $$$n$$$ indices from $$$1$$$ to $$$2n$$$ — indices of the $$$n$$$ arrays that form a good subset (you can print them in any order). If there are several possible answers — pri...
standard output
PASSED
fe7e9b93512c1aa0b018acf30e5b3b38
train_108.jsonl
1626012300
Cirno has prepared $$$n$$$ arrays of length $$$n$$$ each. Each array is a permutation of $$$n$$$ integers from $$$1$$$ to $$$n$$$. These arrays are special: for all $$$1 \leq i \leq n$$$, if we take the $$$i$$$-th element of each array and form another array of length $$$n$$$ with these elements, the resultant array is...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Locale; import java.util.StringTokenizer; public class Solution imple...
Java
["3\n7\n1 2 3 4 5 6 7\n2 3 4 5 6 7 1\n3 4 5 6 7 1 2\n4 5 6 7 1 2 3\n5 6 7 1 2 3 4\n6 7 1 2 3 4 5\n7 1 2 3 4 5 6\n1 2 3 4 5 7 6\n1 3 4 5 6 7 2\n1 4 5 6 7 3 2\n1 5 6 7 4 2 3\n1 6 7 5 2 3 4\n1 7 6 2 3 4 5\n1 7 2 3 4 5 6\n5\n4 5 1 2 3\n3 5 2 4 1\n1 2 3 4 5\n5 2 4 1 3\n3 4 5 1 2\n2 3 4 5 1\n1 3 5 2 4\n4 1 3 5 2\n2 4 1 3 5\n...
2 seconds
["1\n1 2 3 4 5 6 7\n2\n1 3 5 6 10\n4\n1 3 6 7 8 9"]
NoteIn the first test case, the number of good subsets is $$$1$$$. The only such subset is the set of arrays with indices $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$7$$$.In the second test case, the number of good subsets is $$$2$$$. They are $$$1$$$, $$$3$$$, $$$5$$$, $$$6$$$, $$$10$$$ or $$$2$$$, $$$4$$...
Java 8
standard input
[ "2-sat", "brute force", "combinatorics", "constructive algorithms", "graph matchings", "graphs" ]
e284f33d82824afb23042e9dab0956ad
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$5 \leq n \leq 500$$$). Then $$$2n$$$ lines followed. The $$$i$$$-th of these lines contains $$$n$$$ int...
2,800
For each test case print two lines. In the first line, print the number of good subsets by modulo $$$998\,244\,353$$$. In the second line, print $$$n$$$ indices from $$$1$$$ to $$$2n$$$ — indices of the $$$n$$$ arrays that form a good subset (you can print them in any order). If there are several possible answers — pri...
standard output
PASSED
7b1f73f06c34a14add8665082829e649
train_108.jsonl
1626012300
Cirno has prepared $$$n$$$ arrays of length $$$n$$$ each. Each array is a permutation of $$$n$$$ integers from $$$1$$$ to $$$n$$$. These arrays are special: for all $$$1 \leq i \leq n$$$, if we take the $$$i$$$-th element of each array and form another array of length $$$n$$$ with these elements, the resultant array is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.Collection; import java.io.IOException; import java.lang.reflect.Field; import java.util.stream.Collectors; import java.nio.charset.StandardCharsets; import java.ut...
Java
["3\n7\n1 2 3 4 5 6 7\n2 3 4 5 6 7 1\n3 4 5 6 7 1 2\n4 5 6 7 1 2 3\n5 6 7 1 2 3 4\n6 7 1 2 3 4 5\n7 1 2 3 4 5 6\n1 2 3 4 5 7 6\n1 3 4 5 6 7 2\n1 4 5 6 7 3 2\n1 5 6 7 4 2 3\n1 6 7 5 2 3 4\n1 7 6 2 3 4 5\n1 7 2 3 4 5 6\n5\n4 5 1 2 3\n3 5 2 4 1\n1 2 3 4 5\n5 2 4 1 3\n3 4 5 1 2\n2 3 4 5 1\n1 3 5 2 4\n4 1 3 5 2\n2 4 1 3 5\n...
2 seconds
["1\n1 2 3 4 5 6 7\n2\n1 3 5 6 10\n4\n1 3 6 7 8 9"]
NoteIn the first test case, the number of good subsets is $$$1$$$. The only such subset is the set of arrays with indices $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$7$$$.In the second test case, the number of good subsets is $$$2$$$. They are $$$1$$$, $$$3$$$, $$$5$$$, $$$6$$$, $$$10$$$ or $$$2$$$, $$$4$$...
Java 8
standard input
[ "2-sat", "brute force", "combinatorics", "constructive algorithms", "graph matchings", "graphs" ]
e284f33d82824afb23042e9dab0956ad
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$5 \leq n \leq 500$$$). Then $$$2n$$$ lines followed. The $$$i$$$-th of these lines contains $$$n$$$ int...
2,800
For each test case print two lines. In the first line, print the number of good subsets by modulo $$$998\,244\,353$$$. In the second line, print $$$n$$$ indices from $$$1$$$ to $$$2n$$$ — indices of the $$$n$$$ arrays that form a good subset (you can print them in any order). If there are several possible answers — pri...
standard output
PASSED
7ae69df51c65c4be87aa9dcb4c5a4da4
train_108.jsonl
1626012300
Cirno has prepared $$$n$$$ arrays of length $$$n$$$ each. Each array is a permutation of $$$n$$$ integers from $$$1$$$ to $$$n$$$. These arrays are special: for all $$$1 \leq i \leq n$$$, if we take the $$$i$$$-th element of each array and form another array of length $$$n$$$ with these elements, the resultant array is...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class C { FastScanner in; PrintWriter out; boolean systemIO = true; public static void quickSort(int[] a, int from, int to) { if (to - from <= 1) { return; } int i = from; int j = to - 1; int x = a[from + (new ...
Java
["3\n7\n1 2 3 4 5 6 7\n2 3 4 5 6 7 1\n3 4 5 6 7 1 2\n4 5 6 7 1 2 3\n5 6 7 1 2 3 4\n6 7 1 2 3 4 5\n7 1 2 3 4 5 6\n1 2 3 4 5 7 6\n1 3 4 5 6 7 2\n1 4 5 6 7 3 2\n1 5 6 7 4 2 3\n1 6 7 5 2 3 4\n1 7 6 2 3 4 5\n1 7 2 3 4 5 6\n5\n4 5 1 2 3\n3 5 2 4 1\n1 2 3 4 5\n5 2 4 1 3\n3 4 5 1 2\n2 3 4 5 1\n1 3 5 2 4\n4 1 3 5 2\n2 4 1 3 5\n...
2 seconds
["1\n1 2 3 4 5 6 7\n2\n1 3 5 6 10\n4\n1 3 6 7 8 9"]
NoteIn the first test case, the number of good subsets is $$$1$$$. The only such subset is the set of arrays with indices $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$7$$$.In the second test case, the number of good subsets is $$$2$$$. They are $$$1$$$, $$$3$$$, $$$5$$$, $$$6$$$, $$$10$$$ or $$$2$$$, $$$4$$...
Java 8
standard input
[ "2-sat", "brute force", "combinatorics", "constructive algorithms", "graph matchings", "graphs" ]
e284f33d82824afb23042e9dab0956ad
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$5 \leq n \leq 500$$$). Then $$$2n$$$ lines followed. The $$$i$$$-th of these lines contains $$$n$$$ int...
2,800
For each test case print two lines. In the first line, print the number of good subsets by modulo $$$998\,244\,353$$$. In the second line, print $$$n$$$ indices from $$$1$$$ to $$$2n$$$ — indices of the $$$n$$$ arrays that form a good subset (you can print them in any order). If there are several possible answers — pri...
standard output
PASSED
301d8d5ab1fb972e642b60bcfa65c3f9
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
9223f81aacd412de798c8f1b950d6ebe
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
c753bda7720796aa741889e6c84a832b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
c10a95906f329efe9621504ba11e802e
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
a8222dbf96dcca7a4072ec71dc39e024
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
b2d225956bc6f865ec174ce3d5ec0af4
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
f0ee4b7ba8f0ff72a67f7bdbd363b09f
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
872410c0ade551eef666659a3bdc1611
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
abbdd71176025f5e29cbe221397c08d9
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
d020e2110b0d0f907c37f63d7f65b6c2
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); for(...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
7cfed7b4721a1020ba96c798b98c16b1
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
12fd61f8fb51e43d7e3cc7b71978cb36
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class C{ public static void main(String[] args) { FastReader sc = new FastReader(); StringBuilder sb = new StringBuilder(); int t = sc.nextInt(); out:while(t-- >0) { int n = sc.nextInt(); char[] ch = sc.nextLine().toCharArray(); int l =-1; i...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
4a38bf4e1aee58a470ac59721f667782
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); f...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
14bcb0a3b9b939ca163e21952537104e
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); out:while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; cha...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
d508525530d7d379ab39e93c77bcf8e2
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
240a29e6f204420cbf6c9d7cbbbd2c7c
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
cfff3d8dbaec0f7230a12a1a566a379b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); for(...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
cac8a45cff616b832184822a777cb764
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
d49d9af201571fa0c9e4e629eb72a579
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); StringBuilder solve = new StringBuilder(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char pr...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
f4a92b2fc6cdd8458b949458afbf1729
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); f...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
1296dd3ccef7af8890a12bdf0d8fe3b2
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader sc = new FastReader(); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); for(int i=1; i<n; i+=2){ if(s.charAt(i)==s.cha...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
31dd51a5f60d7c091fe1e4a038538c78
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; 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(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); for(int i=1; i<n; i+=2){ if(s.charAt(i)==s.charAt(i-1)){ ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
1f4177b3b20a93872a3d70c44a780e68
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(), ans = 0, ans2=0; char prev = 'w'; String s = sc.next(); for(int i=1; i<n; i+=2){ ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
0f259f275afc08bc7066a88773e1761b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long t = Long.parseLong(br.readLine()); while(t-->0){ int n = Integer.parseInt(br.readLine()); int ans = 0; in...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
360c95e4951e04c03de6370cd35526ce
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ int n = Integ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
3b5ace4db8756e1d964a08251b3f1f5e
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ StringTokeniz...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
331b7093e53316d42da28b0f6f8fbe04
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ StringTokeniz...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
4ffb3724c7495f45c5e6786a6da74cac
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ StringTokeniz...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
e8b0d6c25e72e895286ffe83786d06ac
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ StringTokeniz...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
fbbb8daaf922c1667d559bd6d9a611ac
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ Strin...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
f9ea23c021c25216a387d77b7087d1cb
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t-->0){ Strin...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
3fea85d280501af03a1908e55a869b34
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; public class B1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while(test -- > 0) { int n = sc.nextInt(); String s = sc.next(); long[] cut = calc(s,n); ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
5683078e4cffef77af26889ddff4880b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextInt(); while( t-- ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
457b612a2537a31328d58d0235cc7959
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextInt(); while( t-- ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
f68f55996b869ac1a4e6c4cd46577cc6
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int t; static int n; static char[] a; static int min, segments; public static void main(String[] args) throws IOException { t = in.iscan(); while (t-- > 0) { n = in.iscan(); a = in.sscan().toCharArray(); min = ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
ba5f62870e5df2fe753fd8b3ca62613b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class CF789VC { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStre...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
5ba900c6698f262785e8ccf07d851f0d
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class TaskB { public static void main(String[] arg) { final FastScanner in = new FastScanner(System.in); final PrintWriter out = new PrintWriter(System.out); final int T = in.nextInt(); for (int t = 0; t < T; t++) { final int...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
00005b1d9fbe1f54ace134ac1d57ca61
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; // you can compare with output.txt and expected out public class Round789B { MyPrintWriter out; MyScanner in; final static String IMPOSSIBLE = "IMPOSSIBLE"; final static String POSSIBLE = "POSSIBLE"; final static String YES = "YES"; final static String NO = "NO"...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
2f39161f79a8726f139aad4449adcb22
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.Arrays; import java.util.*; import java.util.Scanner; import java.util.StringTokenizer; public class copy { static int log=18; static int[][] ancestor; static int[] depth; static voi...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
fcabc3082088d1e2ba66d7489d297f02
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Test{ static FastReader scan; static void solveA(){ int n=scan.nextInt(...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
65e4b84796d63e3d062af3b72e1467a6
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class C { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine().trim()); StringBuilder sb = new StringBuilder(); ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
d29bead15066fe6e30fc90efacd38dbb
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class Good01String { public static void main(String[] args) throws IOException { // BufferedReader in = new BufferedReader(new FileReader("Good01String.in")); // PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Good01String.out"))); BufferedReader...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
9564fab38d555f885aa4a9d31d21f971
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class Main { private boolean oj = System.getProperty("ONLINE_JUDGE") != null; private FastWriter wr; private Reader rd; public final int MOD = 1000000007; /************************************************** FAST INPUT IMPLEMENTATION ***********...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
4feb1a0fb67b58ffc3a1e504096248fd
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.Scanner; public class TokitsukazeAndGoodStringH { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); int ans = 0;...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
2b512b2e56f3ae4ebffa0c71eb795766
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
// Contest 1678, Problem B2 // Tokitsukaze and Good 01-String (hard version) import java.io.*; import java.util.*; public class B2 { static BufferedInputStream bis; public static int readInt() throws IOException { int num = 0; int b = bis.read(); while(b < '0' || b > '9') b = bis.read(); while(b >= '0') ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
59da5c13f20bfa31ac77b0093b37ee06
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
2d90400e6f6612e01e3360b2247863d3
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static AReader scan = new AReader(); static int N = 200010; static int[][] dp = new int[N][2]; static void solve() { int n = scan.nextInt(); char[]...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
b6317677bb8c2cb3627d56d4a2a774ca
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.StringTokenizer;...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
ec7583ef8513e1e34d21ff8f65e9b669
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.*; public class b { public static void main(String []args) { MyScanner s=new MyScanner(); int t=s.nextInt(); while(t-->0) {...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
5e0cf1fd74a61464bbbd908fadfc3ccb
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class C{ public static void main(String[] args) { FastReader sc = new FastReader(); StringBuilder sb = new StringBuilder(); int t = sc.nextInt(); out:while(t-- >0) { int n = sc.nextInt(); char[] ch = sc.nextLine().toCharArray(); ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
3a83f76f9a50a6ab43326cb1cafdbca5
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; import java.time.Year; public class Solution { public static void main(String[] args) throws IOException { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); int co...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
301cc08fcb78c3cada1629f3e09e6d22
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class B2 { static IOHandler in = new IOHandler(); public static void main(String[] args) { // TODO Auto-generated method stub int testCases = in.nextInt(); for (int i = 1; i <= testCases; ++i) { solve(i); } } private static void solve(...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
8531e271b695687260153fd4eb12c6c4
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; /** * @author KaiXin * @version 11 * @date 2022-07-12 13:03 */ public class TaskA { static final int SIZE = (int) 2e5 + 5; static String s; static int[][] dp = new int[SIZE][2]; public static void solve(InputReader in,PrintWriter out){ in...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
205aa5f4906887b2a7e416ca23f8473e
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; public class Q1678B { public static void main(String args[]) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0) { int n = s.nextInt(); String a = s.next(); ArrayList<Integer> count = new ArrayList<>(); int c = 1; for(int i=1; i<=n-1; i++)...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
f91d28a3a133e672b01af65e9f6fa706
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.security.cert.X509CRL; import java.util.*; import java.lang.*; import java.util.stream.Collector; import java.util.stream.Co...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
9ee664f72b3508540f182f0d267f16c4
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.pars...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
d37c6f57644913bf473020e1e40321cc
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.Arrays; import java.io.*; import java.util.*; import java.util.Random; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; /* Solution Created: 23:52:31 11/05/2022 Custom Competitive programming helper. */ public class Main { public static class Pai...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
4b0f1e621cdb593eb6dbbe0e3a300d99
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.security.Guard; import java.util.*; import java.util.List; import java.util.stream.IntStream; public class Main implements Runnable { public static final int LIMIT = 100010; int n, m; long k; static boolean use_n_tests = true; int[] a; void solve(Fast...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
8232c7a5783181d9f0212dbf2112844c
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; //import org.graalvm.compiler.phases.graph.FixedNodeProbabilityCache; //import org.graalvm.compiler.phases.graph.FixedNodeProbabilityCache; import java.io.*; import java.math.*; import java.sql.Array; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLIntegri...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
e521d2269c7a98d4b846d0773a533f51
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; public class B1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while(test -- > 0) { int n = sc.nextInt(); String s = sc.next(); long[] cut = calc(s,n); ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
bfa7208f658ab30211b74ec79dfd5281
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static Scanner obj = new Scanner(System.in); public static PrintWriter out = new PrintWriter(System.out); public static int i() { return obj.nextInt(); } public static void main(String[] args) { int len = i(); while (len-- != ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
87a67abe5fdbf5569f46e7a718067b79
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
/** * @description: * @author: dzx * @date: 2022/5/3 */ import java.io.*; import java.util.*; public class Main2 { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastScanner in = new FastScanner(input...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
9a5ac333f0666ef56502328359bab3e3
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class Main { InputStream is; PrintWriter out = new PrintWriter(System.out); ; String INPUT = ""; void run() throws Exception { is = System.in; solve(); out.flush(); out.close(); } publ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
9c59b613e4bf33f758fe9873b7724a03
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.io.*; import java.util.*; public class B2 { void go() { int n = Reader.nextInt(); String s = Reader.next(); char[] c = s.toCharArray(); int ans = 0; int cnt = 0; List<int[]> two = new ArrayList<>(); for(int i = 0; i < n; ) { ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
efefa1d6167e987f463e7bf9058dbf2b
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
// package c1678; // // Codeforces Round #789 (Div. 2) 2022-05-08 07:35 // B2. Tokitsukaze and Good 01-String (hard version) // https://codeforces.com/contest/1678/problem/B2 // time limit per test 1 second; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(fin...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
7d0dfddcd35abea3975ac7121e80f09c
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solutions { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int testCases = Integer.p...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output
PASSED
70cd94291a4d4efd88d44d072ac60673
train_108.jsonl
1652020500
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the mi...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); char[] s = sc.next().toCharArray(); int i = 0; int k = 1; ...
Java
["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"]
1 second
["3 2\n0 3\n0 1\n0 1\n3 1"]
NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There a...
Java 11
standard input
[ "dp", "greedy", "implementation" ]
8c7844673f2030371cbc0cb19ab99b35
The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string ...
1,800
For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.
standard output