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
15114fc8bcc315fd2655b1b52a0b3472
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.*; /** * @author hypnos * @date 2020/11/2 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); PrintWriter writer = new PrintWriter(Syst...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
a1023822195a5b91e5bb9caf15aa7ee2
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int T = scanner.nextInt(); while (T-- > 0) { int n = scanner.nextInt(); int x = scan...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
03fe97622816d6d7e1e44a2b1c1d8ab6
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.*; /** * * @author Aaryan(AV) * AV */ public class Test { public static void main(String[] args) throws Exception { Scanner input = new Scanner(System.in); // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = ne...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
458b6436a481beb0786bcef9ea9ce3e5
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class A { public static void main(String args[]){ Scanner sc=new Scanner(System.in); int tt=sc.nextInt(); while(tt-->0){ int n=sc.nextInt(); int x=sc.nextInt(); Integer a[]=new Integer[n];Integer b[]=new Integer[n]; for(int i=0;i<n;i++){ ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
d3c833d056e78f60775b9d3a1ff9f507
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); for (int g = 0; g < t; g++) { int n = in...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
d3ff758ebcf76c92228ce8bcf20923e8
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception{ Scanner scan = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int iter = scan.nextInt(); for (int i = 0; i < iter; i++) { int sz =...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
e9374f88bc52e26b569d42d2403f14f2
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; import java.io.*; public class B { public static void main(String args[]) { Scanner in=new Scanner(System.in); int t=in.nextInt(); L: while(--t>=0) { int n=in.nextInt(); int x=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<n;i++) a[i]=in.nextInt(); ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
28766c42d9ddd37cd8a2f38c96bfaf89
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String args[]) { Scanner in=new Scanner(System.in); int t=in.nextInt(); L: while(--t>=0) { int n=in.nextInt(); int x=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<n;i++) a[i]=in.nextInt(); ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
54683464a12de85d00b3cf5c81f6d67c
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; import java.io.*; public class C { public static void main(String args[]) { Scanner in=new Scanner(System.in); int t=in.nextInt(); L: while(--t>=0) { int n=in.nextInt(); int x=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<n;i++) a[i]=in.nextInt(); ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
7192413c99aed0a0d732abb107975368
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class VasyaandCornfield { static int mod = 1000000007; static InputReader in = new InputReader(System.i...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
58363dd5d3ed82a87156b2f016b267d2
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.*; public class Main { private Reader r; private StreamTokenizer tk; public Main() { r = new BufferedReader(new InputStreamReader(System.in)); tk = new StreamTokenizer(r); } public void exit() throws IOException { r.close(); } public String readLi...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
6c10941e1e512e57279bc18abcb5a309
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.*; public class Solution { /* A utility function to calculate area of triangle formed by (x1, y1), (x2, y2) and (x3, y3) */ static float area(int x1, int y1, int x2, int y2, int x3, int y3) { return (float)Math.abs((x1 * (y2 - y3) + x2 * (...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
3f098808a2439f1038587a5ea0a2f9a2
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); i...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
47d8dbaa5165d359d0c406f94c66d3ee
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.Scanner; public class An2 { public boolean check(point p1, point p2, point pp) { int A = p1.y-p2.y; int B = p2.x-p1.x; int C = -(A*p1.x + B*p1.y); int D = A*pp.x + B*pp.y + C; if (D>=0) { return true; } else { return false; } } public static void main(String[] args) ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
f128a377282c7e3e1c6d2855e9d0b21f
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Sol2 { public static void main (String[] args) throws java.lang.Exception { int x,y,sum,diff; Scanner sc=new Scanner(S...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
048f8b560a5a570671d140f9247469d4
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.*; import java.util.*; public class VasyaandCornfield { public static void main(String[] t) { int m,n,d,i,x,y,c1,c2,c3,c4; Scanner sc=new Scanner(System.in); n=sc.nextInt(); d=sc.nextInt(); m=sc.nextInt(); for(i=0;i<m;i++) { x=sc.nextInt(); y=sc.nextInt(); c1=(x-y+d); c2=(x+y+...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
eedde231f54ba4b3e0d5c8c5ae4890c3
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
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); public static void main(String[] args) throws IOException { int n = in.nextInt(); int d = in.nextInt(); int m = in.nextInt(); for(int...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
a7e8343e48ad1a55268f45b3c0eccf1a
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { FastReader in = new FastReader(); int n = in.nextInt(); int d = in.nextInt(); int m = in.nextInt(); int x1,x2,x3,x4,y1,y2,y3,y4; ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
da2abffddec24b98a499998bc5f3255f
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
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, D, Q; public static int x1, y1, x2, y2, x3, y3, x4, y4; public static void main(String[] args) throws IOException { BufferedReader f = new Buffer...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
80fcb4e52874ac2044ba7640f712769b
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; public class Main2 { static long mod = 1000000007L; stati...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
033f692788be93e138f497abd10e1f76
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
4f130656421e97a3dc576bcfb57fda02
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner in=new Scanner(System.in); int n=in.nextInt(),m=in.nextInt(),k=in.nextInt(); for (int i=0; i<k; i++) { int a=in.nextInt(),b=in.nextInt(); if (Math.abs(a-b)<=m&&a+b>=m&&a+b<=n+n-m) System.out.println("YES"); ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
fcc7cbf909677d5bab74f8ed46780a4e
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.Scanner; public class SolutionB { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n, d, m; n = input.nextInt(); d = input.nextInt(); m = input.nextInt(); ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
97125b49fca82054f30d96f812c98bf9
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces1058B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int d = scanner.nextInt(); int m = scanner.nextInt(); for(int iM = 0; iM < m; iM++) { int x = scanner.nextInt(); int y = sc...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
980a3c5f4f9b0e660b8226fc051c8ecf
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
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 VasyaAndCornfield { void solve() { int n = in.nextInt(), d = in.nextInt(), Q = in.nextInt(); while (Q-- >...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
f453ff79bba4fdb1b72dc3c58c490882
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author llamaoo7 */ public class Main { public static void main(String[] args) { InputStream ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
cbfe4c98d2b84878eb8a3da673bea8d1
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
/* Solution to http://codeforces.com/contest/1058/problem/B * using geometry library. * * Test for insideness (including boundaries) in convex polygon * @author godmar */ import java.util.*; import java.util.stream.*; import static java.lang.Math.*; public class BCCW { public static void main(String []av) { ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
f17d85b751bfaf1a13345949046367b4
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.*; public class shashwat{ static Scanner in=new Scanner(System.in); public static void main(String args[]){ int n=in.nextInt(); int d=in.nextInt(); int a=in.nextInt(); for(int i=0;i<a;i++){ int x=in.nextInt(); int y=in.nextInt(); if(x+y>=d && x-y<...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
6b3c4f70966ddcf1e5e0822614e0cc04
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.*; public class shashwat{ static Scanner in=new Scanner(System.in); public static void main(String args[]){ int n=in.nextInt(); int d=in.nextInt(); int a=in.nextInt(); for(int i=0;i<a;i++){ int x=in.nextInt(); int y=in.nextInt(); if(x+y>=d && x-y<=d ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
bb10c50799f4371bdd3e8dbff368b2ee
train_001.jsonl
1537707900
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there ar...
256 megabytes
import java.util.Scanner; /** * * @author CHAGO */ public class B { public static void main(String[] args) { Scanner sc = new Scanner (System.in); int n= sc.nextInt(); int d=sc.nextInt(); int m=sc.nextInt(); for (int i = 0; i < m; i++) { int a=sc.nextInt(); ...
Java
["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"]
1 second
["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"]
NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordin...
Java 8
standard input
[ "geometry" ]
9c84eb518c273942650c7262e5d8b45f
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d &lt; n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position ...
1,100
Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
348bea5220eb93c26078e49050b79304
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.lang.reflect.Array; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; public class D541 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(), m = scanner.nextInt(); List<List<Integer>...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
029814a15a0cf9daf964aa57a8580977
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.FileInputStream; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solu...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
370b08de50be964147af6c1b801c5dd3
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.*; import java.util.*; import java.util.LinkedList; import java.math.*; import java.lang.*; import java.util.PriorityQueue; import static java.lang.Math.*; @SuppressWarnings("unchecked") public class Solution implements R...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
0e731db80413e9618ddadbbe85acec14
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
a85ad600a36dd2fd8ff2178afabe7aec
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; import java.lang.*; public class draw{ public static void main(String[] args) { solveGourmet(); } public static void solveGourmet(){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); scan.nextLine(); String[] strs = new String[n]; for(int i=0;i...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
ecbf239daf3317e645147560b3b63676
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.*; import java.util.*; import java.util.function.Function; public class MainD { static int N, M; static char[][] C; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); M = sc.nextInt(); C = new char[N][]; ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
8067779eee46380794a72f6ce17b40ef
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.Reader; import java.io.InputStreamReader; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.LinkedList; impor...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
63c468438f447f15e1495e2e12643bc4
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; /**...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
aeadfb852768226786a9194887c7ef2e
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; /**...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
3eb23a072c888c48676569bcbc727bec
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; public class D{ static class...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
6a9e4eb756526d422149d810103111d8
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (root == null || !root.hasMo...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
a12de02f266b6e0d7e655eb350152d13
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.Scanner; public class Main { public static int[] dsu; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); scanner.nextLine(); int[] a = new int[n * m + 1]; in...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
cdb8fddf422fe967bbbf8d59fb8cf166
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class MainS { static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader; static PrintWriter writer; public static void main(String[] args) { ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
fc259f63b2c9ea66b918b98d2c12409a
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; import java.io.*; public class gourmet { int N, M, nodeN, compN; int[] compID, inEdges, dishScores; boolean[][] adj, rawAdj, equalAdj; gourmet(BufferedReader in, PrintWriter out) throws IOException { StringTokenizer st = new StringTokenizer(in.readLine()); N = Integ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
e4865663edb45c9035eb2f6e37d85c75
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.lang.invoke.MethodHandles; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Pri...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
33fbb7814b8f2f9b5fe1a852a828bf08
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; public class ACM { private static int find(int k, int[] fa) { fa[k] = (fa[k] == k ? k : find(fa[k], fa)); return fa[k]; } public static void main(String[] args) { int N = 2010; Scanner sc = new Scanner(System.in); int n = sc.nextInt(); i...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
5011ac6c76bffec42dac16013226f30a
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.*; import java.util.*; public class cf { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(Reader in) { br = new BufferedReader(in); } public FastScanner() { this(new InputStreamRead...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
824efdb6430707f1193a90c0a27d29df
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.BufferedWriter; import java.util.Collection; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.UncheckedIOExcep...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
7566668ce6ac3d7ef0b6eb8ff0250e69
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; import java.io.*; /* BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); Integer.parseInt(st.nextToken()); Long.parseLong(st.nextToken()); Scanner sc = new Scanner(System.in); */ public class Waw{ static Has...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
d59ed0809738f8e53ecc47717d155566
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Arrays; import java.util.Iterator; import java.util.Collection; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import j...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
8ca39f3b236e049b25711ac9ef5e5d3c
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; public class Main { static ArrayList<Node> V = new ArrayList<>(); /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); char[][] ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
3cc9bae7bdfa6e70607470edea86b510
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @autho...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
6b1b4711dfb8b43a1772a4dd802d8684
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; public class tr0 { static PrintWriter out; static StringBuilder sb; static int mod = 1000000007; static long inf = (long) 1e16; static int[][] ad; static int n, m; static long[][][] memo; static HashSet<Integer> h; ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
1ced771c7ee2a6a7a9f46e160af806f0
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.*; import java.util.*; public class MainClass { static int n, m; static char[][] A; static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder stringBuilder = new StringBuilder(); static boolean[] visited; static int[] ids; static Li...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
dc978a3530e1a45272d432ef18babfe0
train_001.jsonl
1550917200
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d...
256 megabytes
import java.io.*; import java.util.*; public class D { static class DSU { private final int n; private final int[] root; DSU(int n) { this.n = n; root = new int[n + 1]; for (int i = 0; i <= n; i++) { root[i] = i; } } ...
Java
["3 4\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;\n&gt;&gt;&gt;&gt;", "3 3\n&gt;&gt;&gt;\n&lt;&lt;&lt;\n&gt;&gt;&gt;", "3 2\n==\n=&lt;\n=="]
2 seconds
["Yes\n2 2 2 \n1 1 1 1", "Yes\n3 1 3 \n2 2 2", "No"]
NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.
Java 8
standard input
[ "dp", "greedy", "graphs", "dsu", "dfs and similar" ]
016bf7989ba58fdc3894a4cf3e0ac302
The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "&lt;", "&gt;" and "=".
2,000
The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the s...
standard output
PASSED
8302062f5c1e214a9758e5a5dc8b2e7b
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; public class InterestingArray_CodeForces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
5d1a91eecce25a055b19bd2aec5eba3b
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.io.IOException; import java.util.*; //import javafx.util.Pair; //import java.util.concurrent.LinkedBlockingDeque; //import sun.net.www.content.audio.wav; import java.text.DecimalFormat; public class Codeforces { public static long mod = (long)Math.pow(10, 9)+7 ; pub...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
2e1997d022dafaacce91afc92da39854
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedInputStream; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { ScanReader scanner = new ScanReader(System.in); PrintWriter out = new PrintWriter(System...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
3c15c1e6315894670c1449f66bcd4589
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.util.*; public class InterestingArray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int[][] pre = new int[31][n+1]; int[][] queries = new int[3][m]; for(int q = 1; q <= m; q++) { int l = scan.nextInt()-1; ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
9e27a3408cea9c840e30d8e6510eda4b
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.Scanner; import java.util.function.Supplier; public class Application { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); solve(scanner.nextIn...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
c9cf3def7acfff6cf9a3737735db644c
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Main { static long Add[] = null; static long Data[] = null; static operation op[] = null; static int n; private s...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
77970e03bb1b3198b2c612c0786e6e45
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Main { static long Add[] = null; static long Data[] = null; static operation op[] = null; static int n; private s...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
c2df1f1c2c038356a09bccf3961a0d32
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
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.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Main { public static void main...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
7abff981f3ea2f325266e1443c37fcf1
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in Actual solution is at the top * * @author dauom */ public class Main { ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
5e446f26b6aad277e82a0317411e3d7f
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.TreeSet; public class InterestingArray { public static void main(String[] arg...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
b3f33e08ebe338e4fdf5dc6036444112
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solver s...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
e9a3e2a4bd1bb0b9c288497000590696
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
//package Graphs; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class main482B { public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static long mod = (1 << 30) - 1; public static void ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
f728eba87de4eb3d70a9542fdaa70aa4
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
//package Graphs; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class main482B { public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static void main(String[] args) throws IOException { ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
297042ea1b28b5291f50114bea42e210
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
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 InterestingArray { public static void main(String[] args) throws Numb...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
55c199647bd27c6b51ed3526d438591e
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.util.*; public class b implements Runnable{ public static void main (String[] args) {new Thread(null, new b(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println("Go!"); int n = fs...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
b6ccba6201a9488b3405b8f7668853b1
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.*; public class a { public static void main(String[] Args) throws ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
00affce4a2120bbe8326190d4b4ed293
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
7eb5f175ed5999e0c6c29cddd436e62f
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.util.*; public class B { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { int n = nextInt(); int m = nextInt(); int[] low = new int[m]; int[] high = new int[m]; int[] val = new int[m]; for (int i = 0; i < m; i++) { ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
1cbd79e3270fbc1c9455c64f9c1948d1
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { private class Query { private int id; private int l; private int r; private int q; Query(int l,int r,int q,int id) { this.l=l; this.r=r; this.q=q; ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
0e96ba2cd6bbec7a5993f6984a5ceafb
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.*; public class Main implements Runnable { private class Query { private int id; private int l; private int r; private int q; ...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
a73fe24cdfc5ce70c1a2a7c934a115f8
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class B { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); class Triple implements Comparable<Triple> { int l; int r;...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
d37a209ae6e6f534ffc7a197f5f8643f
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
//package DSU; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class B482 { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); SegmentTre...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
e9198d1ffd3691578100fbc78936b965
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
//package SegmentFenwick; import java.io.*; import java.util.StringTokenizer; public class practice { public static void main(String[] args) throws IOException, InterruptedException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine())...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
2cd78059d14916aa4308cde6db2f02a2
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.util.*; import java.io.*; public class abc{ static void Construct(int seg[],int l,int r,int pos,int a[]){ if(l==r){ seg[pos]=a[l]; return; } int m=(l+r)/2; Const...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
696e6683b3a70930721781fc95144e35
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the t...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
a3144e25730c3d0d9283bc4e25a2fb37
train_001.jsonl
1414170000
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi. Your task is to find any interesting array of n elements or state that such array ...
256 megabytes
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the t...
Java
["3 1\n1 3 3", "3 2\n1 3 3\n1 3 2"]
1 second
["YES\n3 3 3", "NO"]
null
Java 8
standard input
[ "data structures", "constructive algorithms", "trees" ]
0b204773f8d06362b7569bd82224b218
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits. Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi &lt; 230) describing the i-th limit.
1,800
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] &lt; 230) decribing the interesting array. If there are multiple answers, print any of them. If the interesting array doesn't exist, print "NO" (without the quotes)...
standard output
PASSED
d85fbba5a71855ddabf5504c29b2dde6
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
import java.io.BufferedReader; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collection; import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.util.StringTokenizer; im...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
fb9d19adfe37d9c6b7720c5fd6ab2e96
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int n = Integer.p...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
6f328b3042cb690a9cfa2fff6e048ed2
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class E38 { public static long mod = 1000000007; public st...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
5665953f8b31c2158e82fb566f0cca25
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.IntStream; import java.util.stream.Stream; public class Main implements Runnable { static final int MOD = (int) 1e9 + 7; static final int MI = (int) 1e9; static final long ML = (long) 1e18; static final Reader in = new Reader(); static f...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
f0df4ff447e0ab4cbf4ad80699a924a8
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
import java.util.*; public class Test { static long dp[][]; public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Marble marbles[] = new Marble[n]; dp = new long[n][n]; for(int i=0;i<n...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
7289531f728b9cfa54ef291e7a6cb293
train_001.jsonl
1288440000
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble num...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int[] x = new int[n], c = new int[n]; Integer[] idx...
Java
["3\n2 3\n3 4\n1 2", "4\n1 7\n3 1\n5 10\n6 1"]
2 seconds
["5", "11"]
null
Java 8
standard input
[ "dp", "sortings" ]
334d2bcb32d88a7037bcf262f49938cf
The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial pos...
1,800
Output the single number — the least fine you will have to pay.
standard output
PASSED
f2d571336a28afe622f8835245e6be11
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
dd1cbefd26055456731a57c98d3f269e
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.*; import java.util.*; public class Typo { public static void main(String[] args)throws IOException { BufferedReader ob=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(ob.readLine()); Map<Integer,Integer> pos=new HashMap<>(); ...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
6feafb476e90c3e3cd9796229b5e5faf
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.Scanner; public class ProblemC { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new B...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
245a7eb6e4e4cd546e2e4d264787417e
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.*; import java.util.*; public class Bracket{ static final int MAXN = 500005; static public void main(String[] args) { InputReader in = new InputReader (System.in); PrintWriter out = new PrintWriter (System.out); int n = in.nextInt(), ans = 0; int[] left = new int [MAXN]; int[] right ...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
2005a6c1c687252905ae3b2b6f480d82
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class FirstStep { static int[] in1; static int[]in2; static int n; static boolean solve(int sum,int id){ if(id==n){ if (sum==0||sum%3...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
e56f63bccfffff56b2c56f96ec5e145d
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
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(); TreeMap<Integer , Integer> map =...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
b535ab7531ecc3bf301b2a298352be0c
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
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(); TreeMap<Integer , Integer> map =...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
98bb299ed5dc7fc1b507b4f792473661
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Stack; import java.util.StringTokenizer; public class c { public static void main(String[] args) { // TODO Auto-generated method stub FastReader s...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
b192e8fc57294a2bc70b617e99ae0888
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
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.*; public class gr1 { static class InputReader { public BufferedReader br; public StringTokenizer token; public InputReader(...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
1e8fe0f91ec70e88e3f96ae4e6d4b5c9
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.util.*; import java.io.*; public class CodeForces { public static void main(String[] args)throws IOException { Scanner sc=new Scanner(System.in); //Scanner sc=new Scanner(new File("ip.txt")); int i,count=0,temp,n,k; n=sc.nextInt(); String out[]=new String[n]; int p[]=new int[n]; for(i...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
3ce1ed66a8e032fd8e74b2dc2e884473
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C { private static class FastReader { private static BufferedReader br; private static StringTokenizer st; public FastReader() { ...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
63ec3a2c74c6a40b4c17e3a88b2eaac6
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
//package CodeForces; import java.util.HashMap; import java.util.Scanner; import java.util.Stack; public class YuhaoAndParanthesis { static boolean isBalanced(String str,HashMap<Integer,Integer> left,HashMap<Integer,Integer> right) { Stack<Character> st=new Stack<Character>(); int a=0;int b=0; for(int i=0;i...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output
PASSED
39328190474b82ea53fa9865f58034f8
train_001.jsonl
1546613100
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting cha...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import j...
Java
["7\n)())\n)\n((\n((\n(\n)\n)", "4\n(\n((\n(((\n(())", "2\n(())\n()"]
2 seconds
["2", "0", "1"]
NoteIn the first example, it's optimal to construct two pairs: "((     )())" and "(     )".
Java 8
standard input
[ "implementation", "greedy" ]
2cfb08b2269dbf5417c1758def4c035f
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of bracket sequences. Each of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")". The sum of lengths of all bracket sequences in the input is at most $$$5 \cdot 1...
1,400
Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.
standard output