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 | cf5d143a0f8414ccd4db984ce0f64424 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {
static PrintWriter out;
static Reader in;
public static void main(String[] args) throws IOException {
input_output();
Main solver = new Main();
solver.solve();
out.close();
out.flush();
}
s... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | d46b58eb8df86413483661c8aca14e88 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {
static PrintWriter out;
static Reader in;
public static void main(String[] args) throws IOException {
input_output();
Main solver = new Main();
solver.solve();
out.close();
out.flush();
}
s... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 61536b03bb95d5f62d965bd1be7ef77e | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.util.*;
public class D {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) throws IOException {
readInput();
... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 3a8d915c146f6ec60849aa2daf6fe396 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.util.*;
public class D {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) throws IOException {
readInput();
... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 351a427c1613f40f90638810a3b3be84 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.util.*;
import java.io.*;
public class D {
static int seg_tree[];
static int a[];
static ArrayList<ArrayList<Integer>> al;
static int count(int start, int end, int val) {
return upperbound(al.get(val), end) - lowerbound(al.get(val), start) + 1;
}
static void bu... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | fc80250366c66d2209ed8c630a19e89c | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.util.*;
import java.io.*;
public class D {
static int seg_tree[];
static int a[];
static ArrayList<ArrayList<Integer>> al;
static int count(int start, int end, int val) {
return upperbound(al.get(val), end) - lowerbound(al.get(val), start) + 1;
}
static void bu... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | fa5d00d65d1409743078ffb3789c9c59 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.util.*;
public class Main {
void run() throws IOException {
int n = nextInt();
int q = nextInt();
ArrayList<Integer>[] a = new ArrayList[n];
for (int i = 0; i < n; i++) {
a[i] = new ArrayList<>();
}
int[] z = new... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 0e1d1197b3617a20f45b70ecfb4a979d | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.util.*;
public class cut_stick {
static int n;
static List<Integer>[] g;
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 88d1203c06f8bef8e71f744dfb5761bc | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes |
import java.util.*;
import java.io.*;
public class CutandStick {
// https://codeforces.com/contest/1514/problem/D
static int n, maxcount=0, numvals=0;
static int[] arr;
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new ... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 612bebf28802a28b82a0165505f97719 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//int cases = Integer.parseInt(br.readLine());
//while(cases-- > 0) {
String[] str = br.readLine().spl... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 6f683de751b95b9e059ac1a0403f3773 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.*;
public class Main {
private static int[] a;
private static Vector<Integer>[] indexSets;
private static void run() throws IOException {
int n... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 7c562e66280091e10ebc36e78c262da5 | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.awt.*;
import java.io.*;
import java.sql.Array;
import java.util.*;
import java.util.List;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | d8a81e9ead86bdc243a1e8766c08256b | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | import java.util.*;import java.io.*;import java.math.*;
public class Main
{
static int block;
static class Node
{
int l,r,ind;
Node(int l,int r,int ind)
{
this.l=l;
this.r=r;
this.ind=ind;
}
}
public static class C... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 9add6d8b08aaa6890dbbd4a85b8a95ad | train_110.jsonl | 1618839300 | Baby Ehab has a piece of Cut and Stick with an array $$$a$$$ of length $$$n$$$ written on it. He plans to grab a pair of scissors and do the following to it: pick a range $$$(l, r)$$$ and cut out every element $$$a_l$$$, $$$a_{l + 1}$$$, ..., $$$a_r$$$ in this range; stick some of the elements together in the same or... | 512 megabytes | //package round716;
import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;
public class D {
InputStream is;
FastWriter out;
String INPUT = "";
int[] ans;
void solve()
{
int n = ni(), Q = ni();
int[] a = na(n... | Java | ["6 2\n1 3 2 3 3 2\n1 6\n2 5"] | 3 seconds | ["1\n2"] | NoteIn the first query, you can just put the whole array in one subsequence, since its length is $$$6$$$, and no value occurs more than $$$3$$$ times in it.In the second query, the elements of the query range are $$$[3,2,3,3]$$$. You can't put them all in one subsequence, since its length is $$$4$$$, and $$$3$$$ occurs... | Java 11 | standard input | [
"binary search",
"data structures",
"greedy",
"implementation",
"sortings"
] | d6c228bc6e4c17894d9e723ff980844f | The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 3 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{n}$$$ ($$$1 \le a_i \le n$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ ... | 2,000 | For each query, print the minimum number of subsequences you need to partition this range into so that the partitioning is beautiful. We can prove such partitioning always exists. | standard output | |
PASSED | 66a81e1956baf4a3a0146d7723c587b7 | train_110.jsonl | 1618839300 | This is an interactive problem.Baby Ehab loves crawling around his apartment. It has $$$n$$$ rooms numbered from $$$0$$$ to $$$n-1$$$. For every pair of rooms, $$$a$$$ and $$$b$$$, there's either a direct passage from room $$$a$$$ to room $$$b$$$, or from room $$$b$$$ to room $$$a$$$, but never both.Baby Ehab wants to ... | 256 megabytes | /*
bts songs to dance to:
I need U
Run
ON
Filter
I'm fine
*/
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1514E
{
public static voi... | Java | ["1\n4\n\n0\n\n0\n\n1\n\n1\n\n1"] | 1 second | ["2 3 3 0 1 2\n\n1 0 1\n\n1 0 2\n\n2 2 1 1\n\n3\n1111\n1111\n1111\n0001"] | NoteIn the given example:The first query asks whether there's a passage from room $$$3$$$ to any of the other rooms.The second query asks about the direction of the passage between rooms $$$0$$$ and $$$1$$$.After a couple other queries, we concluded that you can go from any room to any other room except if you start at... | Java 8 | standard input | [
"binary search",
"graphs",
"interactive",
"sortings",
"two pointers"
] | beae75b649ca6ed26180954faf73e5a3 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases you need to solve. Then each test case starts with an integer $$$n$$$ ($$$4 \le n \le 100$$$) — the number of rooms. The sum of $$$n$$$ across the test cases doesn't exceed $$$500$$$. | 2,700 | To print the answer for a test case, print a line containing "3", followed by $$$n$$$ lines, each containing a binary string of length $$$n$$$. The $$$j$$$-th character of the $$$i$$$-th string should be $$$1$$$ if there's a path from room $$$i$$$ to room $$$j$$$, and $$$0$$$ if there isn't. The $$$i$$$-th character of... | standard output | |
PASSED | 7fc0442c744ab5b34e163933a5cb383c | 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.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Solution2 {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() ... | 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 | 0210866c8be210fddf66102db55098d4 | 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.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Bracket_Sequence_Deletion {
static class RealScanner {
BufferedReader br = 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 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 | 3de30b95aee267bf47e7e73c4e6f2e1c | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | 680680c5f708a76d875648b517c7d1da | 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.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStre... | 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 | 7c0c9da876c1c98d0dc6e5e0c515c3fb | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | 9b324ed4e20bcf2f5023927b399034b7 | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | e0a6ac2dafd0b34b37012427c342c2a4 | 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.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hash... | 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 | 70db6fa821b79964e709ba281bd7b89c | 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.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hash... | 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 | 7a74c689fc80f7a27923275785bfe2bb | 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 class401 {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
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 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 | d939f6e1319cb69bd0f727890a2b07bf | 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();
while(t-- >0) {
int n=sc.nextInt();
char a[]=sc.next().toCharArray();
int cnt=0;
int i=0;
int last=-1;
while(i<n) {
boolean open=(a[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 | b84975ce0e9e04e487844d0f690a05c9 | 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 Main
{
static long mod = (int)1e9+7;
static PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
public static void main (String[] args) throws java.lang.Exception
{
FastReader sc =new FastReader(... | 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 | 85e9ecddee5d90a5328cc37362c9ed97 | 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) throws IOException {
//FileReader fr = new FileReader(new File("input.txt"));
InputStreamReader sr = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(sr);
StringBuilder ... | 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 | 145385bd8f050d26ca18c5f2c48f0eb5 | 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 C {
public static void main(String[] args) {
Scanner go = new Scanner(System.in);
int t = go.nextInt();
while (t-->0){
int n = go.nextInt();
String s = go.next();
int ans = 0;
int pos = 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 | 72cb23ab13d550d049e60c7e49fd7666 | 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 | /*
++:,,;:,,,,,,,,:;:,,,,,,;:;;,,,,,,,:+:,;+;:,,,,,,,::,,:+;+;,,,,,,,,,,,,,,,:;,,::,:;,,,,:,,,,:;+;:,:,,,,:,,,,,,,,,,,,:,,,
++,,:;,,,,,,,,,:+:,,,,,:;;+:,,,,,,:;;:;;:,,,,,,,,,::,,;;;+;:,,,,,,,,,,,,,,;;,,::,,;,,,,:,,,,,,;+;:;:,,,;,,,,,,,,,,,,::,,
+;,,::,,,,,,,,,:+;,,,,,:++;,,,,,,:+;:+;:,,,,,,,,,,;,,,+;;+;:,,,,,,,,,,,,... | 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 | d6b85627f076a8d80a6240ba71b8bfc9 | 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 {
private static class pair implements Comparable<pair> {
int low, high;
pair(int low, int high) {
this.low = low;
this.high = high;
}
@Override
public int hashCode()
{
... | 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 | 74aaa2c4f991ec9e229240faa26e488e | 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.text.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
PrintWriter writer = new PrintWriter(System.out);
int t = sc.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 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 | 2e9c0724a6ca8ecba6127a86206125e2 | 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 {
// when can't think of anything -->>
// 1. In sorting questions try to think about all possibilities like sorting from start, end, middle.
// 2. Two pointers, brute force.
// 3. In graph query questions try to solve it reversely or try to proc... | 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 | b84a30956e3fc1d7feead3c9575b126b | 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 {
private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
private FastWriter wr;
private Reader rd;
public final int MOD = 1000000007;
/************************************************** FAST INPUT IMPLEMENTATION ***********... | 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 | 47666f689e670948a1ac8f759ba7ab18 | 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 CFE125_C {
// public static void main(String[] args) {
// Scanner cs=new Scanner(System.in);
// int t=cs.nextInt();
// while(t-->0){
// int n=cs.nextInt();
// String s=cs.next();
// int x=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 | cfe638f419e0df9fa46723a2b5f1dab0 | 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 CFE125_C {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int t=cs.nextInt();
while(t-->0){
int n=cs.nextInt();
String s=cs.next();
// int x=0;
// int y=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 | d5ccfeb84ba033c99792a0699a289f8c | 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.math.*;
import java.io.*;
public class Solution {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMore... | 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 | 013a60276ca0af314c97b558ec7b992c | 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 Bracket extends PrintWriter {
Bracket() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
Bracket o = new Bracket(); o.main(); o.flush();
}
void main() {
int t = sc.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 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 | 1c4f9f998852eab0f4e52cf767d11537 | 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 B {
static FastScanner fs = new FastScanner();
static PrintWriter pw = new PrintWriter(System.out);
static StringBuilder sb = new StringBuilder("");
public static void main(String[] args) {
int t = fs.nextInt();
for (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 | 21b8ce2ad159b9ad4b3ed228110cf925 | 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.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Print... | 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 | ae2d1e7cc79ab9d2432d24ab63e17676 | 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 cf {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == n... | 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 | fcf898c3d591b4ffb946f7389adb2271 | 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 BracketSequenceDeletion {
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();
char[] ch=s.toCharArray();
int i=0,j=1,cnt=0;
while(j<n) {
if(ch[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 | e887a9ca6fbb1e13a0d982b5f5c1b8e7 | 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 Solution{
public static String get_ans(int l, String brackets){
int key = 0;
char ch;
int operations = 0;
int rem = l;
int len = 0;
while(key < l){
ch = brackets.charAt(key);
... | 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 | d3e132c0d138e199b6d5d2f37a551d75 | 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 |
/*
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /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 | 389621c95201cf99b1e34f7d12b1010a | 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 cf1657Ca {
public static void main(String[] args) {
FastReader in = new FastReader();
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int n = in.nextInt();
String s = in.nextLine();
int coun... | 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 | df6a7d172ac15bb2a39e8186500c6135 | 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.text.DecimalFormat;
import java.util.*;
public class Main
{
static class Pair
{
int u,d;
public Pair(int u,int d)
{
this.u=u;
this.d=d;
}
public String toString() {
return u+" "+d;
... | 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 | d50ab4c6fb2dab0f33a964698334019f | 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 | /**
* 03/22/22 morning
* https://codeforces.com/contest/1657/problem/C
*/
// package codeforce.ecf.r125;
import java.util.*;
import java.io.*;
public class C {
static PrintWriter pw;
void solve(int n, String s) {
int i, remove = 0;
for (i = 0; i + 1 < n; ) {
char... | 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 | e999e56073d7c97ae66064c390928d95 | 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.*;
public class Test
{
final static FastReader fr = new FastReader();
final static PrintWriter out = new PrintWriter(System.out) ;
static long mod = (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 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 | 4619bd6812487d2fe66d05c0e8f6300a | 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 cf1657C {
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 i = 0;
int j = 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 | 49b4d54b79058dc0fd4ebaa832b91a59 | 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 BracketSequenceDeletion {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
String str=sc.next();
StringBuilder str1=new StringBuilder();
StringBuilder ... | 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 | 4dfd3902c902783833dd869969ad1305 | 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 Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
String str=sc.next();
StringBuilder str1=new StringBuilder();
StringBuilder str2=new StringBuil... | 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 | 73a79bc8c38546ffcc2dc5fa29662997 | 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 Kattio io;
static long mod = 998244353, inv2 = 499122177;
static {
io = new Kattio();
}
public static void main(String[] args) {
int t = io.nextInt();
for (int i = 0; i < t; i++) {
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 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 | edece68804de60a10829a7b67384b2d6 | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | b707594262ccb409da9cb1cf1712efe7 | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | a842dc0c30f0d91d30bb0727da6ab010 | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | 2afdd20580c7b3aa751e5a5ae32ce677 | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
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 | cfc78d8b25c1f5e916bceff02a1624db | 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Test{
static FastReader scan;
static void solve(){
int n=scan.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 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 | bf35392864239a8dcf6920f8cd2ac37c | 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 {
final static int mod = 1000000007;
final static String yes = "YES";
final static String no = "NO";
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int t = 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 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 | 02a1961703a0d9f024e3e7f0a072468e | 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 PrintWriter out;
static Kioken sc;
public static void main(String[] args) throws FileNotFoundException {
boolean t = true;
boolean f = false;
if (f) {
out = new PrintWriter("output.txt");
... | Java | ["5\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 | e355b1d1bd4b545cdbc02bb1b8a2dabd | 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.*;
public class fire extends PrintWriter {
fire() { super(System.out); }
static Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
fire o = new fire(); o.main(); o.flush();
}
void main() {
int t = sc.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 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 | 5c7ee0262c9403d932e1f48c3171523f | 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.Stack;
public class BSD {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseI... | 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 | 35e38561ff14844da95c40d054df0fdf | 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 AC {
public static void main(String args[]) throws IOException {
FastReader sc = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int tc, i, j;
String s;
char p;
tc = 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 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 | 044faf02c19adeac7f6eab43d4674ca5 | 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.*;
public class C_Bracket_Sequence_Deletion{
static final int MOD = (int) 1e9 + 7;
public static void main (String[] args){
FastReader s = new FastReader();
int t=1;t=s.ni();
outer: for(int test=1;test<=t;test++){
int n = 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 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 | 564b7dfddba1ff9351336018182ac776 | 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 Solution{
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t>0){
t--;
int n = scn.nextInt();
scn.nextLine();
String s = scn.nextLine();
int ans=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 | 299e2bd6d303983004c7a3fcb77edf60 | 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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
/**
* Built using 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 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 | 090f7848e5ec8c929ba111acecd6517b | 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.text.*;
import java.math.*;
import java.util.regex.*;
public class JaiShreeRam{
static Scanner in=new Scanner();
static long mod = 1000000007;
static List<List<Integer>> adj;
static int seive[]=new int[1000001];
static long C[][];
static long ans=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 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 | 20dd56a07e8698fc994b36a2461f144c | 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.util.StringTokenizer;
public class C {
static InputReader reader;
public static void main(String[] args) throws IOException {
reader = new InputReader(System.in);
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 | 99ce1c8525285cdf076b02442245b6b0 | 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 |
/*
* akshaygupta26
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public class C {
static long mod = (long) (1e9 + 7);
public static void main(String[] args) {
F... | 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 | bf85f6914158cd8e02e17f8838c21a04 | 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.StringTokenizer;
public class C1657C {
public static void solve (int n, String s){
int index = 0;
int operations = 0;
while (index < n){
if (s.charAt(index) == '('){
... | 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 | 97fbeeb0e846b492cbedaa2e404366e9 | 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 | /***** ---> :) Vijender Srivastava (: <--- *****/
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static FastReader sc =new FastReader();
static PrintWriter out=new PrintWriter(System.out);
static long mod=(long)32768;
static StringB... | 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 | c0a3a047ba8d955fdf021148f0ba8118 | 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 | /***** ---> :) Vijender Srivastava (: <--- *****/
import java.util.Queue;
import java.util.LinkedList;
import java.util.*;
import java.lang.*;
// import java.lang.reflect.Array;
import java.io.*;
public class Main
{
static FastReader sc =new FastReader();
static PrintWr... | 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 | 9139c3a696c77eab37d1a77fd7e0add0 | 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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public clas... | 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 | c0d75c18c96d3323909fac79be770e82 | 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_Bracket_Sequence_Deletion{
public static void main(String[] args) throws Exception{
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while(t-->0){
int n = fr.nextInt();
String 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 | 56d1e4d123d9e71b190527cad9dbfc14 | 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 claas{
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;
int i=0;
while(i<n) {
if(s.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 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 | 25ab37746f7d756a21210cb571aee23b | 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 java.util.*;
import java.io.*;
import java.math.*;
public class C_Bracket_Sequence_Deletion {
public static void main(String[] args) {
OutputStream outputStream = 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 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 | 7264ad8c6a35fcef2cf4b515d2f963df | 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 java.util.*;
import java.io.*;
import java.math.*;
public class C_Bracket_Sequence_Deletion {
public static void main(String[] args) {
OutputStream outputStream = 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 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 | dc94e453f77d241d3bab55c803c33bcf | 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 |
// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class C1657 {
public static void main(String[] args) {
FastReader fs = new FastReader();
int t = fs.nextInt();
StringB... | 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 | 5c1272a1769d6c701b6e0356829b3a54 | 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.Stack;
import java.util.StringTokenizer;
import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.in;
import static java.lang.System.out;
public class Bracket_Sequence_Delet... | 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 | d25772d100d53779f1e5b2637a1defbe | 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 CF1657C extends PrintWriter {
CF1657C() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF1657C o = new CF1657C(); o.main(); o.flush();
}
void main() {
int t = sc.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 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 | 74f20a5b5b009dedaccf83ac52acbc96 | 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 cf;
import java.util.Scanner;
public class barket_sequence {
static boolean pd(int l,int r,String a) {
int n=(r-l+1)/2;
//System.out.println(n);
for(int i=0;i<n;++i) {
if(a.charAt(l+i)!=a.charAt(r-i))return false;
}
return true;
}
public static void main(String[] args) {
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 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 | 6577d4b98da0e32fd9315ca7bd4ff8c6 | 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
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = 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 | a022867eff5b894fe9a259e6ae036b9b | 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
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = 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 | 7a735eefd7ef4de44d44f52ffc6238e8 | 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.IOException;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
StringBuilder ansStr = new StringBuilder();
while (t-->0){
int n = sc.n... | 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 | 4e14eade9bf803effa3d9f95fd0f6077 | 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 {
static Scanner sc = new Scanner(System.in);
static StringBuilder out = new StringBuilder();
static String testCase = "Case #";
static long mod = 998244353;
public static void main(String[] args) throws IOException {
// TODO Auto-ge... | 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 | adabb561a9423e3b64dacfd00db6d4e0 | 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 cp1 {
public static void main(String[] args)throws Exception {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while(t-->0) {
int n=Integer.parseInt(br.readLine());
String s1=br.readL... | 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 | 3a16d61af48dfc689859ea4328a16f20 | 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 javax.swing.plaf.synth.SynthPasswordFieldUI;
import java.io.*;
public class a {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (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 | f98c36d5f89c8d5d23f81b49c5c5d25c | 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.lang.*;
import java.util.*;
public class BracketSequenceDeletion {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- > 0) {
int n = s.nextInt();
String st = s.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 | 9e7fdc693e7edd6920589927cfb37624 | 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.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.math.BigInteger;
public final class Main{
static class Reader {
... | 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 | 26ae92798486d31c31b89719dda7c76f | 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 java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import jav... | 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 | 1d05cbae69f2fc165461b651d83ac739 | 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 java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import jav... | 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 | 1e9513c547474270a4f69d80960b5f9b | 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 codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner cin=new Scanner(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 | 5e217ebac7f5dba94582c2b95a61a2f7 | 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.*;
public class CF{
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
long t= Long.parseLong(sc.nextLine());
for(int z = 0; z < t; z++){
long n = Long.parseLong(sc.nextLine());
String 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 | ae203b6866856e1044579060d29c2f56 | 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 | //not all import are used to solve every problem .. but these are the most important one
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class ... | 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 | 846c333b3fb1d55fba7c643819a96b20 | 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.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class edu125c {
static boolean areBracketsBalanced(String expr) {
Deque<Character> stack
= new ArrayDeque<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 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 | d4f2ab4798793cc83e76160b52f208f4 | 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 codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Solution
{
static boolean f=false;
static int ans=0;
static int lasti=-1;
public stat... | 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 | 03fb97949fea11f01a6ea5cb7ced39a9 | 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 Main
{
static long mod = (int)1e9+7;
// static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main (String[] args) throws java.lang.Exception
{
FastReader sc =new FastReader();
... | 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 | b8140a5b53a45f4bd2c34b670a2d0a1a | 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 Codeforces;
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class template{
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next () {
while(!st.hasMoreTo... | 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 | 2b9b468531ce32a800df57f012811805 | 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 {
int qwe = in.nextInt();
while (qwe-- > 0) {
int n = in.nextInt();
String s = in.next();
char[] str = s.toCharArray();
int 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 | ca0677b0b849323b4b63099cdbf5a793 | 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.lang.*;
import java.util.*;
public class ComdeFormces {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
// Reader.init(System.in);
FastReader sc=new FastReader();
BufferedWriter log = new BufferedWriter(new OutputStreamWriter(Sys... | 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 | 75741fe4db3ca08a3060abb91e4e461e | 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.lang.*;
import java.util.*;
public class Main {
public static int mod = (int) 1e9 + 7;
// **** -----> Disjoint Set Union(DSU) Start **********
public static int findPar(int node, int[] parent) {
if (parent[node] == node)
return node;
... | 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 | c30fe494f98b687b8466894973b528d0 | 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 CodeForcesTest {
static class Pair{
int f;
int s;
Pair(int f,int s){
this.f=f;
this.s=s;
}
}
public static void main(String[] args) throws IOException {
FastReader sc=new FastReader();
BufferedWriter out = new B... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.