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
d0ee27c2eb576078833c093d4bc19433
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { static StringBuilder sb; static dsu dsu; static long fact[]; static int mod ; static int test; static int tc; static void solve() { int n=i(); String s=s(); int idx=0; int op=0; while(idx<n-1){ char c1=...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
1c388073fde4247e847df3a5534fe401
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) { while (N-- > 0) { solve(); } out.close(); } public static void solve() { int n = sc.nextInt(); String s = sc.nextLine(); int start = 0; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
f66a243ae1bdd8b15cc90352719bb216
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; public class pb1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0){ int n = sc.nextInt(); char[] str = sc.nex...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
a7cbd39d9d16c66561dd2d3a468d0968
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
//package prog_temps; import java.util.*; import java.io.*; public class Java_Template { static boolean[] primecheck = new boolean[1000002]; static int M = 1000000007; static int mn = Integer.MIN_VALUE; static int mx = Integer.MAX_VALUE; static int vis[]; static ArrayList<ArrayList<Integer>...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ce294596dad763139f261b555bf62768
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.InputMismatchException; public class A { static InputReader in; static OutputWriter out; public static void main(String[] args) throws FileNotFoundException{ in = new InputReader(System.in); out = new OutputWriter(System.out); if (System.getProperty("...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
536e80a2223b190952eecd5715781051
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Main{ static HashSet<String>h=new HashSet<>(); static HashSet<String>h1=new HashSet<>(); static int gcd(int a,int b){ if(a==0){ return b; } if(b==0){ return a; } return gcd(b,a%b); } public...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
0d80e68bd849742c66d2a1cbf40e9c6a
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Solution{ public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
05672f74fd0b5805f16bef37d1ed8b04
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); while (t > 0) { int n = sc.nextInt(); sc.nextLine(); String s = sc.nextLine(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
5aac84a34785e824a74b568f31f869e9
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); while (t > 0) { int n = sc.nextInt(); sc.nextLine(); String s = sc.nextLine(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
4d2c1bd6afaafcbecd96d3b87e7e3339
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t --> 0) { int n = in.nextInt(); String s = in.next(); int i = 0, left = 0, cnt = 0; while (i < n-1) ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
956b16515af21a59e605168c19b4bd97
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; //-------------------------------///////////////****/////////******////////// //------------------------------------///**********//*****//********//*****// //-----------------------------------///**********//*****//********//*****// //---------...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d3b04fb0613ed60254898c8abfc1d74b
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
482ca49ec16cbb8165bed71639afcfa5
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Stack; import java.util.StringTokenizer; public class C { static final FastReader sc = new FastReader(); st...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
445bdf41f927ee1c5ceb6a546ae63776
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { try { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-->0) { long n = sc.nextLong(); String s = sc.next(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
78dd44216b6f81522535f04df0ecb52b
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
//package Rishab; import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.util.Map.Entry; public class Main { static int dirx[]= {-1,1,0,0};static int diry[]= {0,0,-1,1}; static final PrintWriter out = new PrintWriter(System.out, true); static final FastScanner sc = new FastSca...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
76b6c1c826d65e9b6bb309e8188294d2
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
//package Algorithm; //package Algorithm; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.Scanner; public class main { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub Buffer...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
444ddcc67682805734bca4692581b620
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class JoinSet { int[] fa; JoinSet(int n) { fa = new int[n]; for (int i = 0; i < n; i++) fa[i] = i; } int find(int t) { if (t != fa[t]) fa[t] = find(fa[t]); retu...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d7adcb967455cd01154351032034b25c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Codeforces { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); String in=sc.next(); n = in.length(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
dc2b0fd7bfe7a05d9a6698a79f5fc448
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.Math.PI; import static java.lang.Math.min; import static java.lang.System.arraycopy; import static java.lang.System.exit; import static java.util.Arrays.copyOf; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b3284dea05dc576342d8a5970a853a7c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.Math.PI; import static java.lang.Math.min; import static java.lang.System.arraycopy; import static java.lang.System.exit; import static java.util.Arrays.copyOf; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
0047865e10ad5d0e7da902be44f5dfdf
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; /** * * @author eslam */ public class IceCave { static class FastR...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d3d057a00ebb2bd78de08f504304d437
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; /** * * @author eslam */ public class IceCave { static class FastR...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
2649ffeca4a63b24281ac4b0a8b98576
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 21:21:26 22/03/2022 C...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
8c3015e4a282b99d9dfc0a30a828f846
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
//Break in nested for loops creates problem in java import java.util.*; import java.io.*; import java.lang.*; //import java.util.stream.*; public class A { static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new Inp...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
466787e5772808f0f185dd62406b2762
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { private static boolean palin(String s,int l,int h){ while(l<h){ if(s.charAt(l)!=s.charAt(h)) return false; l++; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
8c89f486964731121a9427f9cce3593b
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static void main(String args[])throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0){ int n=Integer.parseInt(br.readLin...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
9317e1b60a1ac1cd8e71ca63a68c994d
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Solution { static int mod=1000000007; static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new I...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
756b8781ed89ad76c89ca82d760978a6
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class BracketSequenceDeletion { public static void main(String[] args)throws java.lang.Exception{ Scanner scn=new Scanner(System.in); long a=scn.nextLong(); while(a-->0){ long b=scn.nextLong(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
207434fd39e54fac7de6ab1c58202a71
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Play { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t -- > 0) { int n = sc.nextInt(); sc.nextLine(); String expression =...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
a0b1d0cbf428a699091cced31b9ae601
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
// package codeforce; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.io.*; public class A { static class Node { int id1; int id2; int ind ; Node(int v1, int w1, int i){ this.id1= v1; this.id2=w1; this.ind=i; } No...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
98a6a5cf581d88879b7032b31e65bf3d
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class C_Bracket_Sequence_Deletion{ 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; in...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
1e97f11534db3e30c1f491b34a95a812
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { static final long MOD = (long)(1e9 + 7); static int stoi(String s) { return Integer.parseInt(s); } static long stol(String s) { return Long.parseLong(s); } public static void main(String[] args) throw...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 11
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
810df9869fd4e25681e3070583f646f1
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) { new Thread(null, new Main(), "").start(); } public void run() { ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
862c324ff78d6cdf9f2ebb0a127655b8
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); Hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
26bf2bb0386ccc9f2d1697d2b4a47586
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d6a72de8230618d7db58864e92741d79
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
10d4b5329a502c639a45d92ad9081133
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ca373e7b825221ebf4e1ab747356e4a8
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3f9e86eb5405cd8a39b3069639f8c109
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3856e8a76ccc287a5726ea53eddca104
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); char[] a = s.toCharArray(); hash h = ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
8efdda97bf9243aff2a35db9c00f3cf4
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { long[]mo=new long[1000000]; mo[0]=1; for(int i=1;i<1000000;i++){ mo[i]=mo[i-1]*3; mo[i]%=mod; } // for(int i=1;i<20;i++){ // ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d07d6657434e4663cbc90fc3e803ca26
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { /* A Java program to answer queries to check whether the substrings are palindrome or not efficiently */ // static int p = 101; // static int MOD = 1000000007; // // // Structure to represent a query. A query consists...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
856cd2ef780d16b6a7083da87b1072d8
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class C1657 { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(r.readLine()); for(int i = 0; i < T; i++) { int n=Inte...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
63e328fb06137c814c4d1ea316b2a030
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Program { public static void println(Object str) { System.out.println(str); } public static void printArr(Object[] arr) { for(int i=0;i<arr.length;i++) { System.out.print(arr[i]+" "); } System.o...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
bae235b28711cfc2b84b1882e2e2a0db
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Program { public static void println(Object str) { System.out.println(str); } public static void printArr(Object[] arr) { for(int i=0;i<arr.length;i++) { System.out.print(arr[i]+" "); } System.o...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b59e481eb517e1eb5f23f0ca6a6a7041
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.currentTimeMillis; import static java.lang.System.out; import java.util.*; import java.io.*; public class P_1657_C { static class InputReader { public Buffe...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d550040dfc91494ec2afe597eedb104a
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; //import javafx.util.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); public static void main (String[] args) throws java.lang.Exception { int t = i(); while(t-- > 0...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d2a7b5aaf5cb83409892be8e88b80a19
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.StringTokenizer; public class EduC { static FastScanne...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b776338280cb4bc94a885a6a7d6f8740
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class C{ static MyScanner sc; static PrintWriter out; static { sc = new MyScanner(); out = new PrintWriter(System.out); } public static boolean isPalindrom(int x,int y,String s){ while(x<=y){ if(s.charAt(x++)!=s.charAt(y--)) return fa...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ea0cd91d8c712bb7ca53addc239907f4
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class cp{ public static void main(String[] args)throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); StringBuilder sb=new StringBuilder(); while(t-->0){ ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
2955ed3b88087d2f8805334c939c1308
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class BracketSequenceDeletion { static boolean chk(LinkedList s){ if(s.size() == 1) return false; for(int i=0 , j = s.size()-1; j>i ;i++,j--) if(s.get(i) != s.get(j)) return false; return true; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
dbeee2c0c40a9b1b640c53ba1a265d48
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class BracketSequenceDeletion { static boolean chk(LinkedList s){ if(s.size() == 1) return false; for(int i=0 , j = s.size()-1; j>i ;i++,j--) if(s.get(i) != s.get(j)) return false; return true; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
0a8add23159af6727608718afa82c3f2
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class BracketSequenceDeletion { static int c; static boolean chk(LinkedList l){ if(l.size() == 1) return false; for(int i=0 , j = l.size()-1; j>i ;i++,j--) if(l.get(i) != l.get(j)) return false; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
cb95184566ba36f75f2a44d7dd8f363b
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class CodeForces { public static void main(String[] args) throws FileNotFoundException { FastScanner fs = new FastScanner(); int tt = fs.nextInt(); while(tt-- > 0) { int n = fs.nextInt(); char[] a = fs.next().toCharArray(); int i = 0; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ca1930d4bb8f2002f799e9284be6f2ce
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
461401e00a6efc76f8397ba4d8d2223b
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.awt.*; import java.util.*; import java.io.*; public class Codeforces { static FScanner sc = new FScanner(); static PrintWriter out = new PrintWriter(System.out); static final Random random = new Random(); static long mod = 1000000007L; static HashMap<String, Integer> map = new ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
f0acf53312f39be88a11d1b2f87f5f92
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class Main { /// // Two theorams are used to find ncrp // Lucas theoram and the fermit theoram // a^p-1=1(modp) ex...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
49212448fc87e03e7893c6325c8ff1b3
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.lang.*; import java.io.InputStreamReader; import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.File; import java.io.PrintStream; import java.io.PrintWriter; import java.math.BigInteger; pu...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
83a2c13ae0415f8f24621186582c1822
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.lang.*; import java.io.InputStreamReader; import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.File; import java.io.PrintStream; import java.io.PrintWriter; import java.math.BigInteger; pu...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
9f887652b994625960e25fbc514e4213
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Demo{ // public static long gcd(long a, long b) { // if (b==0) // return a; // return gcd(b, a%b); // } // public static void pA(int n, int[] arr) { // for (int i=0; i<n; i++) { // System.out.print(arr[i]+" "); // } // Sy...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b057962437540fd874c54bce1ba4c732
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Stack; import java.util.StringTokenizer; public class C { ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
e6bcbfc2ad9bf84af43e2719a189599c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.*; import static java.lang.System.out; import static java.lang.Math.*; public class pre16 { static class FastReader { Buffere...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
c48cbb8fe83ef40807bb942d741db835
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { new Thread(null, () -> new Main().run(), "1", 1 << 23).start(); } private void run() { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3e91388fdae6b8d4c882e872fd7678ff
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
// package com.company; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.PriorityQueue; i...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
1b45d0dcd14fb8894d4afaed259dd295
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
/** * @Jai_Bajrang_Bali * @Har_Har_Mahadev */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class practice2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); whil...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3208aadc57a2a89bf723fd2c0a2e8326
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.awt.image.ImageProducer; import java.util.*; public class Solution { static boolean prime[] = new boolean[1000001]; static Set<Long> cubes=new HashSet<>(); static { long N = 1000000000000L; // // // for(int i=1;i*i<=n;i++) // { // long...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
fdca35d31c45da2645a98b12212f37df
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class C { public void solve(Scanner in, PrintWriter out) { int t = in.nextInt(); for (int c = 0; c < t; c++) { int n = in.nextInt(); char[] seq = in....
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
48ea80115b05d719dc5e6d6ce2401997
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class Pentagram { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int tc = sc.nextInt(); while(tc-->0){ int n = sc.nextInt...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
4058fbf268a7c2b8a16c8649a5553e43
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class CodeforcesEdu125{ static long mod = 1000000007L; static MyScanner sc = new MyScanner(); static void solve(){ int a = sc.nextInt(); int b = sc.nextInt(); if(a==0 && b==0){ out.println(0); return; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ed973458d719c903aeaa9da570ceae84
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; //import java.text.DecimalFormat; import java.util.*; import java.util.function.LongToIntFunction; public class Codeforces { static int mod= 998244353 ; public static void main(S...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
031c4a5134bf677030cfce855a795c51
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.math.BigInteger; import java.util.*; public class A { static ArrayList<Integer>[] adj; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int oo = 0; oo < t; oo++) { int n = sc.nextInt(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
d5aa893c02b093ca671ce0879e220d34
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class BracketDeletion { public static void main(String[] args) { try { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int testcases = in.nextInt(); while (testcases-- > 0) { int n = in.nextInt(); String s =...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b51a75f5f5170c16acf1664b9c0178b0
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class cp { static PrintWriter w = new PrintWriter(System.out); static FastScanner s = new FastScanner(); static int mod = 1000000007; static class Edge { int src; int wt; int nbr; Edge(int src, int nbr, int ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
6343b25e8616fb78e5c83cb98230a887
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class practice { public static void solve() { Reader sc = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); char[] arr = sc.next().toC...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
c932e92aa3d5a38a44223cda8c132370
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.Scanner; public class C1657 { 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.nextInt(); String S = in.next(); int steps = 0; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
35888d6bf5cd0e8b4a7090dccce67895
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); String str = in.next(); int sum = 0; int s = 0; for (int i = 1; i < n; ) { if (str.charAt(i) == '...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b0023a97a168e29f61dd0d061dabdcae
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class BasicCode { static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(String file) throws FileNotFoundException { br = new BufferedReader(...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
828ad22f62bf92e0c6b8bd81aed27fbc
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author cpp */ public class Main { public static void main(String[] args) { Inp...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
48e82261cf614003ea3ecc67c6954a94
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; 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.Comparator; import java.util.HashMap; import java....
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
09498efdecfb059abfbd7dbc9720338f
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class C{ public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t-->0){ int n=s.nextInt(); String S=s.next(); char c[]=S.toCharArray(); in...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
082b171c404afc539a4c97392217502f
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pranay */ pu...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3ac3e669b5715bde79df60c2161ddb3f
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class C { static int t,n,s,opt,size; static char c[]; static boolean ok; static Scanner sc=new Scanner(System.in); static BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer in=new StreamTokenizer(bf)...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
b75910334fe1e7a64d18b10b86931302
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class C { static int t,n,s,opt,size; static char c[]; static boolean ok; static Scanner sc=new Scanner(System.in); static BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer in=new StreamTokenizer(bf)...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
0060d767f638c5aa240f102d7f14ac1e
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class Main{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=1;i<=t;i++) { int n = sc.nextInt(); String str = sc.next(); int firstIndex = 0; int lastIndex = 1; int opr = 0; ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
c9c4833b8104ae6da170a9727410d177
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); while(num > 0){ int length = scanner.nextInt(); scanner.nextLine(); ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
2921a7bedc0d1f0d67600f145439de25
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t>0) { int n = sc.nextInt(); ArrayList<Character>...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
6d517faa98774f03b87f3849bec3947c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main (String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0){ int n=Integer.parseInt(br.readLine()); St...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
bd0819369fbf69a42d0b3f0eca02e964
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { /* * Aim 1: Do 200 DP codeforces problems * Aim 2: Beat Sparsh in ratings before 2 june. * */ static long fans[] = new long[200001]; static long inv[] = new long[200001]; static long mod = 1000000007; st...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
3fb4c256ed44290b6c312680c45569f0
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
// package EDURound125; import java.io.*; import java.util.*; public class C { // GOGIGO!!! public static void main(String[] args) throws IOException { // all possible prefix to remove :- (( , )) ,)(),() ,))( // Scanner sc = new Scanner(new FileReader("input.in")); // PrintWriter ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
68a1a665ede402025172552d24497f46
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.Scanner; public class cfContest1657 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); StringBuilder sb = new StringBuilder(); while (t-- > 0) { int n = scan.nextInt(); Str...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
6f8f68af4d3640875684990f47a31934
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); // static int g[][]; static ArrayList<Int...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
92a56bac44cd2c79cf98591986d26c7c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Stack; import java.util.Vector; import java.io.Writ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
df53940b1aa02d887e69a78846c6cb83
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static boolean check(char a[], int left, int right) { while (left < right) { if (a[left] != a[right]) { return false...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
a7b3db48ecc9c40b6d5df089f2808f97
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.Scanner; import java.util.Stack; 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(); ch...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
baed42da34e426a7236a6f878e03ae6c
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
//package com.company.codeforces; import java.io.*; import java.util.*; public class BracketSequenceDeletion { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; InputReader in = new InputReader(inputStream); BufferedWriter out = new Buffered...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
8e1320b548b03d7b90cba4a3b77d7e1f
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static final int INF = 0x3f3f3f3f; static final long LNF = 0x3f3f3f3f3f3f3f3fL; public static void main(String[] args) throws IOException { initReader(); int t=nextInt(); while (t--!=0){ ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
82529e8d1c1adf54893707157980c34a
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { ...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
fa22156ff3f41896abd2a4f2507386aa
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.io.*; import java.util.*; public class BracketSequenceDeletion { public static PrintWriter out; public static void main(String[] args)throws IOException{ Scanner sc=new Scanner(); out=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { int n=sc...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
2ae455e3232aef11c1404379fd452cc1
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; public class HelloWorld { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int t = in.nextInt(); while(t-->0) { // )(() // )(() int n = in.nextInt(); String s = in.next(); char[] arr = s...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output
PASSED
ba84a647869e4cea6a677ec1e84c311d
train_110.jsonl
1647960300
You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of t...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); String st=sc.next(); int l=...
Java
["5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()("]
2 seconds
["1 0\n1 1\n2 0\n1 0\n1 1"]
null
Java 8
standard input
[ "greedy", "implementation" ]
af3f3329e249c0a4fa14476626e9c97c
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case ...
1,200
For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.
standard output