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
5c52ba5c751977b536d56d9c64ca63c4
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.math.*; import static java.lang.Math.*; import java.security.SecureRandom; import static java.util.Arrays.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import sun.misc.Regexp; import java.awt.geom.*; import java.awt.image.BufferedImage; import java...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
7a6fe2c5af10d5b6d7b64d4a8529b07c
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class Greg_and_Graph { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Reader r=new Reader(); int n=r.nextInt(); long dis[][]=new long[n][n]; for(int i=0;i<n;i++){ for...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
305a775e716c242a9b52b827d07daa95
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; public class source { static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer strt = new StreamTokenizer(bf); ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
f7c24f27cca7408acb9bb1b8763b768a
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
/** * Created by Alex on 10/20/2014. */ import java.io.*; import java.util.*; public class B295 { BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !in.hasMoreTokens()) { in = new StringTokenizer(br.readLi...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
71457afbe63e40248fa039e9964f8022
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class B { static StringTokenizer st; static BufferedReader...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
53bf2c1b08ee11b5561f0242e4621737
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.Scanner; /** * Created with IntelliJ IDEA. * Author : Dylan * Date : 2013-07-22 * Time : 13:29 * Project : Greg and Graph */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] grap...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
6a0b42824786bec1309ec297704f605d
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.BigInteger; public class Main { public static void main(String args[]) throws FileNotFoundException, IOException { //Scanner in =new Scanner(new FileReader("input.txt")); //PrintWriter out = new PrintWriter(new FileWrit...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
0f2f3f8471005ffd9fdf30f651b96408
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
d03d180778d82074e5c4574041ce5af7
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; public class B { private static Scanner in; public void run() { int inf = Integer.MAX_VALUE / 3; int n = in.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); } } int[] p = new int[n]; for (int i = 0; ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
877ff7980191d8d32fac49db975f96ce
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static StreamTokenizer in = new StreamTokenizer(System.in); public static int ni() throws Exception {in.nextToken(); return (int)in.nval;} public static void main(String[] args) throws Exception { int n1 = ni(); ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
3a190b9f0adaaaf1ed70f2c1c981a9c7
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static StreamTokenizer in = new StreamTokenizer(System.in); public static int ni() throws Exception {in.nextToken(); return (int)in.nval;} public static void main(String[] args) throws Exception { int n1 = ni(); ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
2c1afdaaa3c0033bc14ff27bdb2870c1
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper pl...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
6fd2cc32adb45f1d4cb19fc9baba4396
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static StreamTokenizer in = new StreamTokenizer(System.in); public static int ni() throws Exception {in.nextToken(); return (int)in.nval;} public static void main(String[] args) throws Exception { int n1 = ni(); ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
68d20ded91fc468840636e9f8055e9b3
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static StreamTokenizer in = new StreamTokenizer(System.in); public static int ni() throws Exception {in.nextToken(); return (int)in.nval;} public static void main(String[] args) throws Exception { int n1 = ni(); ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
00f8cb61685fed5f2aaac6112e40e0ed
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { int N = nextInt(); int[][] a = new int[N][N]; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) a[i][j...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
edb5a5969e26ea9a47a68e795416b81e
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { FastScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); } } int[] p = new int[n]...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
64f164458c19646e38a71a07141462bc
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { FastScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); } } int[] p = new int[n]...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
f86973e86c46840069ea9b036fd75dd1
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { FastScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); } } int[] p = new int[n]...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
326cf1e893df0890ed7697b69df9b053
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[]args){ ScanReader in=new ScanReader(System.in); int n=in.nextInt(),x=0,y,z; int[][]D=new int[n][n]; for(;n>x;++x) for(y=0;n>y;D[x][y++]=in.nextInt()); Deque<Integer>V=new ArrayDeque<Integer>(n); for(;0<x--;V.push(in.ne...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
f3143bbd828a43e24bfa28b60d36942a
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[]args){ ScanReader in=new ScanReader(System.in); int n=in.nextInt(),x=n,y,k=n; int[]V=new int[n],D[]=new int[n][n]; for(int[]E:D) for(y=0;n>y;E[y++]=in.nextInt()); for(;0<x;V[--x]=in.nextInt()-1); boolean[]F=new boolean...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
692a011036e75d3319f8b7af9485cb9c
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.List; import java.io.IOException; import java.util.InputMismatchException; import java.util.ArrayList; import java.util.NoSuchElementException; import java.m...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
30a914b91e94da34512563c499c5ec35
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.util.*; public class Problem295B { public static void main (String [] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[][] matrix = new long[n+1][n+1]; int[] r = new int[n+1]; for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) matrix[i][j]...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
c47f0cbda1331316034ef108a552a364
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Pav...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
a2f201e03da8ccdd404714ac053fb42a
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.LinkedList; public class CFFF { static PrintWriter out; static final int oo = 987654321; public static void main(String[] ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
f95fc1c755b39043f23681c67a59579b
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
/* ID: nikchee1 PROB: Greg and Graph LANG: JAVA */ import java.io.*; import java.util.*; public class Main { static Scanner in = new Scanner(System.in); static int N = in.nextInt(); static long[][] D = new long[N + 1][N + 1]; static int[] remove = new int[N + 1]; static long[] ans = new long[N]; publi...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
7ab0db37cae2dd9285e11b8f9ac9a2f6
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class sol { private static BufferedReader in; private static StringTokenizer tok; private static PrintWriter out; private static String readString() throws IOException { while (tok == null || !tok.hasMoreTokens()) { ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
18129e3960f861732573fdc8a562bcd7
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Locale; import java.io.OutputStream; import java.util.RandomAccess; import java.io.PrintWriter; import java.util.AbstractList; import java.io.Writer; import java.util.List; import java.io.IOException; import java.math.BigDecimal; import ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
59d52e8ce122fcd8021adf93ffaa6d2c
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; public class B { void solve() throws IOException { int n = nextInt(); long[][] d = new long[n][n]; long[][] a = new long[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = nextLong(); } } for (int i = 0; i < n; i++) { for (int j...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
1544427e0d39dfbbde66baa62311b295
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class GregAndGraph { private static int n,INF=100000000; private static int adjMatrix[][] = new int[5...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
ab50a0a02aa8f4b39ee6136393391d4f
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { static int n; public static void main(String[] args)throws Exception{ BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); n=Integer.parseInt(br.readLine()); long[][] dist=new long[n+5][n+5]; String[] in...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
d01abba649b45363ad6887a551569665
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { OutputStream outputStream = System.out; InputStream inputStream = System.in; InputFast in = new InputFast(); PrintWriter out = new PrintWriter(outputStream...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
b7cbc06dbb32552af8aa54b4699a2b48
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper pl...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
4744944246cef31408610b20ab803285
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static BufferedReader in; public static PrintWriter out; public static void main(String[] a...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
3ed40b315c0c687d56e6f63b29d2083e
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; public class Pr295B { public static void main(String[] args) throws IOException { new Pr295B().run(); } BufferedReader in; PrintWriter out; StringTokenizer st; String nextToken() throws IOException { while (st == null || !st.hasMoreTokens()) { st = new StringTokeniz...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
5545f8f3c7763d70cabe26344cd1b70b
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class B implements Runnable { static BufferedReader in; static PrintWriter out; static StringTokenizer st; static Random rnd; final int inf = Integer.MAX_VALUE; class Edge implements Comparable<Edge> { int u, v, d; public Edge(int u, int v, ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
bcdc59da62430c4539dad8d1cdd3ce44
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class GregAndGraph { public static void main(String[] args) throws Exception { InputReader in = new InputReader(System.i...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
c1d8ca434bf44fdd25040b17b70f2e31
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.*; import java.util.*; public class B295 { BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !in.hasMoreTokens()) { in = new StringTokenizer(br.readLine()); } return in.nextToke...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
5ee78560be04491a7fa746ff29aa65e2
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C20 { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.pa...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
a0f5fcb11169713116d75dfad3cc8e3f
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws Exception { int nodeCnt = nextInt(); long[][] graph = new long[nodeCnt][nodeCnt]; for (int i = 0; i < nodeCnt; i++) { ...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
686d9a0df7a481cd06df4eefda2e785b
train_001.jsonl
1365694200
Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number xi from the graph. As Gr...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { void solve() { int n = sc.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = sc.nextInt(); int[] x = new int[n]; for (int i = 0;...
Java
["1\n0\n1", "2\n0 5\n4 0\n1 2", "4\n0 3 1 1\n6 0 400 1\n2 4 0 1\n1 1 1 0\n4 1 2 3"]
3 seconds
["0", "9 0", "17 23 404 0"]
null
Java 7
standard input
[ "dp", "graphs", "shortest paths" ]
46920a192a8f5fca0f2aad665ba2c22d
The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct...
1,700
Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.
standard output
PASSED
3d422068b04df6ed66a77b3f421affcf
train_001.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args) { int n=0,a1=0,a2=0,a3=0,a4=0,count=0; Scanner sc=new Scanner(System.in); n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); if(a[i]%4==0) ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 11
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
e80ae7954005d9792cfa13f83114de3e
train_001.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Arrays; public class Solution { public static vo...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 11
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
3b118162075393807d953034728b887e
train_001.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Arrays; import java.lang.Math; public class Solution ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 11
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
b26740a13bd3871dcf456ce0d9393675
train_001.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.ut...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 11
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
69ce90653b19d459d4d677719a5ae13c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
//TEMPLATE V2 import java.io.*; import java.util.*; import java.math.*; public class Main { //Solution goes below: ------------------------------------ static class Node{ int br; int op; int cl; Node(){//Filler node. br=0; op=0; cl=0; } Node(int b, int o, int c){ br=b; op=o; cl=c; ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
054e5e2e659f90ce227cc8447fb79d4c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
//TEMPLATE V2 import java.io.*; import java.util.*; import java.math.*; public class Main { //Solution goes below: ------------------------------------ static int[][] tree; static int[] Go(int level, int pos){ //This is recursive, and should run in O(log N) time. int[] n = tree[level+pos]; int l = (int...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
130ce798212d7be9677f4a2df976d089
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
//TEMPLATE V2 import java.io.*; import java.util.*; import java.math.*; public class Main { //Solution goes below: ------------------------------------ static int[][] tree; static int[] Go(int level, int pos){ //This is recursive, and should run in O(log N) time. int[] n = tree[level+pos]; int l = (int...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
308ebbc9a4c3d11f9717ebc0a879d557
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; 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.StringTokenizer; public class A { static final int INF = (int)1e9; public static void main(Stri...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
21836417a1790d77943ad9e5c6d71559
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; public class C380 { static class SegmentTree { int n; int tree[][]; int start[]; int end[]; ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
62116f727a72eba2c7541203c67c5c2b
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.math.*; import java.security.KeyStore.Entry; import java.util.*; public class TestClass { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; private static SpaceCharFilter filter; private static Pri...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
f34014f447a61566ee3238c828227fcb
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; /* * Heart beats fast * Colors and promises * How to be brave * How can I love when I am afraid to fall... */ //read the question correctly (is y a vowel? what are the exact constraints?) //look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) public class Main...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
8e066ddcb91e57ee182f20a252294e32
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.Stack; /** * Created by lenovo on 3/6/2016. */ public class Brackets { public static void main(String[] args) throws IO...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
bab4e08378fed62d699de030951da9ce
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static int N, Q; public static String str; public static node[] nodes; public static void main(String[] args) throws IOException { BufferedReader f = new Buff...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
4d1dbff33c4df29d5cc57484b2cc6ab0
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static int N, Q; public static String str; public static node[] nodes; public static void main(String[] args) throws IOException { BufferedReader f = new Buff...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
554bf24e08fbbe641e006aa6dc21db75
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction; public class Main { static Prin...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
0f654c6fe9256ec58d2a1153dd07e58d
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
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.StringTokenizer; public class Seraj_brackets { static int mod;...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
0ea964f2182c9d529df8744ed23508f4
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SerejaBrackets { public static void main(String[] args) throws IOException { long start = System.currentTimeMillis(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
5e4b6465f39445dcc7ebdf784463f747
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; public class Serejandbrackets { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
e212770fe6b6c65b13814ea219a32c4d
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; // tutorial public class Solution { static int[] low = new int[1200000 * 4]; static int[] high = new int[1200000 * 4]; static int[] tot = new int[1200000 * 4]; static ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
ac08d9daa555e58f137416bc00a2334e
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.String; import java.util.Scanner; public class C{ public static void main(String[] args) { // TODO Auto-generated method stub BufferedReader reader = new BufferedReader(new In...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
a545002bb1f8d5c8ae3e4915e377d79c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Deque; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { Bu...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
749bd36b27956fbc4f0445ad88d726ff
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
//package CF; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class D { static class Pair { int open; int close; int ans; public Pair(int a,int b, int c){ open = ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
47581a1a64d12363d1f82dd1ab8e0860
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
//package CF; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class D { static class Pair { int open; int close; int ans; public Pair(int a,int b, int c){ open = a...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
63807ae6dd1a5d5a3f026038efb41c00
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.*; public class code1 { private static boolean oj = System.getProperty("ONLINE_JUDGE") != null; privat...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
215f37df79b727f384cade7768e9aa9c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { static class Reader { private BufferedReader br; private StringTokenizer token; protected Reader(FileReader obj) { br = new BufferedReader(obj, 32768); token = null; } ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
8957aac6da7ab7984c5d432cd3fa0a55
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class SegmentTree { static class tri{ int a;int b;int c; tri(int x,int y,int z) { a=x;b=y;c=z; } } int N; //the number of elements in the a...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
797bb33513f1d84fff74c776cbe91bf0
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class C380 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); String x = sc.next(); int n = x.length(); int N = 1; while (N < n) N <<= 1; // pa...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
dc14fe0dd5162d3c21a34328ca2a852d
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class SegmentTreeBracket2 { private static String s; private static int[] valids; private static int[] leftB...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
ea076642ab89e910f8670c8bfce5a854
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.util.*; import java.io.*; public class SegmentTreeBracket { private static String s; private static int[] valids; private static int[] leftBrackets; private static int[] rightBrackets; private static int[] v; private static int[] l; private static int[] r; public static vo...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
4a251eeb8bd5b4e470efc7027fafc508
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; public class Solut...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
ee929d10f44421261e8e37da55c9181c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class SerejaBrackets2 { int n; Node[] t; void solve() { char[] s = in.nextToken().toCharArray(); ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
90e9dd095a300a07f1fbb1a7131e48df
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class SerejaBrackets2 { int n; Node[] t; void solve() { char[] s = in.nextToken().toCharArray(); ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
b934b38c64579cd54a9189613abd4c87
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; public class Parens { static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer in; static int nextInt() throws IOException { ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
69d45860158db2f702338ffb44ddc20c
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; public class Parens { static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer in; static int nextInt() throws IOException { ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
631378cff494367aada1a7ce40ee2087
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Parens { static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StreamTokenizer in; static int nextInt() throws I...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
63479128aa1431db86c325948df96539
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
/** * * @author meashish */ import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Serializable; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
01d1343e66bc597f7282a3a2c7aedc50
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.util.*; import java.io.*; /** * * @author umang */ public class C380 { public static int mod = 1000000007; public static class SegmentTree { int[][] st; SegmentTree(String s, int n) { int x = (int) (Math.ceil(Math.log(n) / Math.log(2))); int max_size =...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
b9de74b4d0e3fec6e60ad5a40365c943
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.nio.charset.StandardCharsets; import java.util.StringTokenizer; import static java.lang.System.currentTimeMillis; public class Algo9 { public static char[] s; public static int m; //public static int[][] a; public static int output; public static int[][] t; //pub...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
bf215ff4f950810bbec463b2fdb8cea0
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; public class jkl{ static int seg[]; public static void main(String args[]){ Scan sc=new Scan(System.in); char ch[]=sc.next().toCharArray(); int n=ch.length; int dp[]=new int[n+1]; seg=new int[4*n+1]; for(int i=0;i<n;i++){ ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
3414773f564970b2cc7ef81848b532cb
train_001.jsonl
1389540600
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of s...
256 megabytes
import java.io.*; import java.util.*; public class SerejaAndBrackets{ static int[] tree; static int n; static void build(int[] aa) { for (int i = 0; i < n; i++) tree[n + i] = aa[i]; for (int i = n - 1; i > 0; i--) tree[i] = Math.min(tree[i << 1] , tree[i << 1 | 1]); ...
Java
["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10"]
1 second
["0\n0\n2\n10\n4\n6\n6"]
NoteA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is string x = sk1sk2... sk|x| (1 ≤ k1 &lt; k2 &lt; ... &lt; k|x| ≤ |s|).A correct bracket sequence is a bracket sequence that can be transformed into a correct aryphmetic expression by inserting characters "1" and "+" betwe...
Java 8
standard input
[ "data structures", "schedules" ]
a3e88504793c44fb3110a322d9dbdf17
The first line contains a sequence of characters s1, s2, ..., sn (1 ≤ n ≤ 106) without any spaces. Each character is either a "(" or a ")". The second line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains a pair of integers. The i-th line contains integers li, ri (1 ≤ li ≤ ri ...
2,000
Print the answer to each question on a single line. Print the answers in the order they go in the input.
standard output
PASSED
0556287b455b35d9406fa524d7c548e5
train_001.jsonl
1587911700
You are given an array $$$a$$$ consisting of $$$n$$$ elements. You may apply several operations (possibly zero) to it.During each operation, you choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$; $$$i \ne j$$$), increase $$$a_j$$$ by $$$a_i$$$, and remove the $$$i$$$-th element from the array (so the indic...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; ...
Java
["4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14"]
7 seconds
["3\n6 8\n1 6\n4 1\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0"]
NoteIn the first test case, the sequence of operations changes $$$a$$$ as follows:$$$[2, 1, 3, 5, 1, 2, 4, 5] \rightarrow [2, 1, 3, 5, 1, 4, 7] \rightarrow [1, 3, 5, 1, 6, 7] \rightarrow [2, 3, 5, 6, 7]$$$.
Java 8
standard input
[ "dp", "bitmasks", "brute force" ]
2ff113d7c71c6e91c8254cbdaf27e9ae
The first line contains one integer $$$T$$$ ($$$1 \le T \le 10000$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \le n \le 15$$$) — the number of elements in the initial array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$...
3,000
For each test case, print the answer as follows: In the first line, print $$$k$$$ — the minimum number of operations you have to perform. Then print $$$k$$$ lines, each containing two indices $$$i$$$ and $$$j$$$ for the corresponding operation. Note that the numeration of elements in the array changes after removing el...
standard output
PASSED
f31796e72e61c826527d68c2adf022e6
train_001.jsonl
1587911700
You are given an array $$$a$$$ consisting of $$$n$$$ elements. You may apply several operations (possibly zero) to it.During each operation, you choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$; $$$i \ne j$$$), increase $$$a_j$$$ by $$$a_i$$$, and remove the $$$i$$$-th element from the array (so the indic...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; ...
Java
["4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14"]
7 seconds
["3\n6 8\n1 6\n4 1\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0"]
NoteIn the first test case, the sequence of operations changes $$$a$$$ as follows:$$$[2, 1, 3, 5, 1, 2, 4, 5] \rightarrow [2, 1, 3, 5, 1, 4, 7] \rightarrow [1, 3, 5, 1, 6, 7] \rightarrow [2, 3, 5, 6, 7]$$$.
Java 8
standard input
[ "dp", "bitmasks", "brute force" ]
2ff113d7c71c6e91c8254cbdaf27e9ae
The first line contains one integer $$$T$$$ ($$$1 \le T \le 10000$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \le n \le 15$$$) — the number of elements in the initial array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$...
3,000
For each test case, print the answer as follows: In the first line, print $$$k$$$ — the minimum number of operations you have to perform. Then print $$$k$$$ lines, each containing two indices $$$i$$$ and $$$j$$$ for the corresponding operation. Note that the numeration of elements in the array changes after removing el...
standard output
PASSED
21c0161ffdd3c08ecc92281709310c89
train_001.jsonl
1587911700
You are given an array $$$a$$$ consisting of $$$n$$$ elements. You may apply several operations (possibly zero) to it.During each operation, you choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$; $$$i \ne j$$$), increase $$$a_j$$$ by $$$a_i$$$, and remove the $$$i$$$-th element from the array (so the indic...
512 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int as...
Java
["4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14"]
7 seconds
["3\n6 8\n1 6\n4 1\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0"]
NoteIn the first test case, the sequence of operations changes $$$a$$$ as follows:$$$[2, 1, 3, 5, 1, 2, 4, 5] \rightarrow [2, 1, 3, 5, 1, 4, 7] \rightarrow [1, 3, 5, 1, 6, 7] \rightarrow [2, 3, 5, 6, 7]$$$.
Java 8
standard input
[ "dp", "bitmasks", "brute force" ]
2ff113d7c71c6e91c8254cbdaf27e9ae
The first line contains one integer $$$T$$$ ($$$1 \le T \le 10000$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \le n \le 15$$$) — the number of elements in the initial array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$...
3,000
For each test case, print the answer as follows: In the first line, print $$$k$$$ — the minimum number of operations you have to perform. Then print $$$k$$$ lines, each containing two indices $$$i$$$ and $$$j$$$ for the corresponding operation. Note that the numeration of elements in the array changes after removing el...
standard output
PASSED
c5896bdb8ba077c3ea3fd040764e14ea
train_001.jsonl
1587911700
You are given an array $$$a$$$ consisting of $$$n$$$ elements. You may apply several operations (possibly zero) to it.During each operation, you choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$; $$$i \ne j$$$), increase $$$a_j$$$ by $$$a_i$$$, and remove the $$$i$$$-th element from the array (so the indic...
512 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int as...
Java
["4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14"]
7 seconds
["3\n6 8\n1 6\n4 1\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0"]
NoteIn the first test case, the sequence of operations changes $$$a$$$ as follows:$$$[2, 1, 3, 5, 1, 2, 4, 5] \rightarrow [2, 1, 3, 5, 1, 4, 7] \rightarrow [1, 3, 5, 1, 6, 7] \rightarrow [2, 3, 5, 6, 7]$$$.
Java 8
standard input
[ "dp", "bitmasks", "brute force" ]
2ff113d7c71c6e91c8254cbdaf27e9ae
The first line contains one integer $$$T$$$ ($$$1 \le T \le 10000$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \le n \le 15$$$) — the number of elements in the initial array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$...
3,000
For each test case, print the answer as follows: In the first line, print $$$k$$$ — the minimum number of operations you have to perform. Then print $$$k$$$ lines, each containing two indices $$$i$$$ and $$$j$$$ for the corresponding operation. Note that the numeration of elements in the array changes after removing el...
standard output
PASSED
e3cd62a48451d29deb8ee98f43772335
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class pr1118C { static int[][] res = new int[25][25]; static int n; public static void main(String[] args) throws IOException { BufferedR...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
ac55353a7306d3ab7561abbcf05af91a
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.Scanner; @SuppressWarnings("unchecked") public class Solution { // 22:25- public static void main(String[] args) throw...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
6fe4fcd6f7d27e6c7fd12b7baa4a64f1
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.Scanner; @SuppressWarnings("unchecked") public class Solution { // 22:25- public static void main(String[] args) throw...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
c44e189f999fd40ad6625d8ead531fd2
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.Scanner; public class C { static Scanner scanner = new Scanner(System.in); static int[] a; public static void main(String args[]) { int n = scanner.nextInt(); scanner.nextLine(); a = new int[1001]; for (int i = 0; i < n * n; i++) { int x = scan...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
1356fceceb9b6a66dbbdf0b3e89a5907
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; /** * @author johnny16 * */ public class PalindromicMatrixMusin { /** * @param args */ static class IntIntPair implements Comparable<IntIntPair> { public...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
61f45483e515fecb4868f95269520620
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; @SuppressWarnings("Duplicates") public class ProblemC { public static void main(String[] args) throws IOException{ ...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
1456621c035936f2c24679d66c8c0198
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = n...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
2537c37109cfbe50290be581db6b83d5
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.*; import java.util.*; public class C { static StringBuilder st = new StringBuilder(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in) ; PrintWriter out = new PrintWriter(System.out) ; int n = sc.nextInt() ; HashSet<Integer> set = new Has...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
ca1192b029458625b72273c493193584
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Scanner; import java.util.Set; public class ProblemC { public static class Number { int num, freq; Number(int num) { this.num = num; this.freq = 1; } } public static ...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
a87f0a2f17da38aefa65d992f4986d5a
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Test77{ PrintWriter pw = new PrintWriter(System.out); InputStream is = System.in; Random rnd = new Random(); int a; void run(){ a = ni(); int k = a*a; TreeMap<Integer, Integer> h = new TreeMap<>(); ...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
3f8df2eb0eeda5b9d39e3aa529bff7a6
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.*; import java.io.*; public class Test { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[n * n]; int[][] ans = new int[n][n]; int max = 1005; int[] cn...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
86cf52be795efbdd37e4cbefb0e1ae36
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class GFG77 { static int mod1 = (int) (1e9 + 7); static class Reader { final private int BUFFER_SIZE = 1 << 16; Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(Syst...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
191c6ae96045e4c9cb8c6adbbd653525
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj = {0, -1, 1, 0}; static int ...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
70911664b500e9dca83335c0bc82e341
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package Round540Div3; import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; /** * * @author Hemant Dhanuk...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
2044e0c927f8d02d407ec030ef5509c7
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.*; import java.io.*; import java.util.HashMap; import java.util.Map; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); Ar...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output
PASSED
d6001ecd99920b18f4b3e61d9192342b
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; public class C { static class InputReader { private static final int DEFAULT_BUFFER_SIZE = 1 << 16; private static final InputStream DEFAULT_STREAM = ...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting...
standard output