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
8597f0718fc41b8fe639138834ab8ce4
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { static FScanner sc = new FScanner(); static PrintWriter out = new PrintWriter(System.out); static final Random random = new Random(); static long mod = 1000000007L; static HashMap<String, Integer> map = new HashMap<>(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
a5186ea692f93316bf173cd7618accbf
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package codeforces.round766div2; import java.io.*; import java.util.*; import static java.lang.Math.*; public class B_Editorial { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); solve(i...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
23906bb6fea90355dc8dfbab1f4e6a51
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package codeforces.round766div2; import java.io.*; import java.util.*; import static java.lang.Math.*; public class B { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); solve(in.nextInt(...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
2c6e13829e085bba206def30bcecd2c7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); for (int i = 1; i <= T; i++) { int n = in.nextInt(); int m = in.nextInt(); List<Integer> dist = getDist(n, ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
571b0a71ad4a49b1f598ed5330ad35a7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); int T = I...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f148f0fbc7bcb8abd6a6cc4fa3f18ec1
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Random; ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
96ff8f0ef182502a3fe1e7b9c80f047c
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class solution{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0){ int n = sc.nextInt(); int m = sc.nextInt(); PriorityQueue<Integer> q=new PriorityQueue<>(); for(int i=0;i<n;i++) ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
944fee0d2f62d1eb2743c4ce4d788442
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class Q1627B { public static void main(String[] args){ Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-->0){ int a = scn.nextInt(); int b = scn.nextInt(); // int[][] mat = new int[a][b]; Pr...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
7cd224912a6f93482c24c8b6f72de049
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Coder { static StringBuffer str=new StringBuffer(); static int n, m; // if Rahul is at (i, j).. Tina wants to sit at max // Among all such max.. Rahul wants to take min static void solve(){ List<Integer> pos=new ArrayList<>(...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
90b62a20152ef4dc5f3a7926b16d810e
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Coder { static StringBuffer str=new StringBuffer(); static int n, m; static void solve(){ List<Integer> pos=new ArrayList<>(); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ // 0,0 0,m-1 n-1,m-1 n-1,0 ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f848112d6103055bf38a3ad20005f879
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; import java.lang.Math; import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; public class Main { static PrintWriter pw; static Scanner sc; static StringBuilder ans; static long mod = 1000000000+...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
8dd394da5f8fcd7e0e814486e8014cf5
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int round = in.nextInt(); for (int z = 0; z < round; z++) { int n = in.nextInt(), m = in.nextInt(); int center = 1; if (n % 2 == 0) center *= 2; if (m % 2 == ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
21d26324ca0a5f1a52ed1f2ffdf56c97
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args)throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(System.out); int t=Integer.parseInt(br.readLine()); while(t-->0) ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
9ef372c9815d0737b06848734648294d
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class q2 { private static boolean isValid(int r, int c, int n, int m) { if(r<0 || c<0 || r>=n || c>=m) { return false; } return true; } public static void main(String[] args) throws IOException { Bu...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
12799896e48b40048a54a4b2c8023d44
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// package com.company; import javafx.scene.AmbientLight; import java.io.PrintWriter; import java.util.*; public class NotSitting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int t = scanner.nextInt...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
6dc8a2439fd069b45e0c56e0a9359e7e
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int i, j, k, n, m, t, y, x, sum = 0; static long mod = 998244353; static FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); static String str; static long ans; public static...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
e0c4aafd62cf55894cf888f2abe2bb61
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int i, j, k, n, m, t, y, x, sum = 0; static long mod = 998244353; static FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); static String str; public static void main(String[] ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
c11b08256e2109838e15265a590a95ad
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class C{ public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t-->0){ int n=s.nextInt(); int m=s.nextInt(); int min=n-(n+1)/2 + m- (m+1)/2; int max=n-1...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
cd0d2fedb78bd2875287912627b1dc39
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args)throws IOException { FastScanner scan = new FastScanner(); PrintWriter output = new PrintWriter(System.out); int t = scan.nextInt(); for(int tt = 0;tt<t;tt++) { int n = scan.nextInt(), m = scan...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
3b1e0402ab24106b1fed5a8b0ba839a8
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /** * @author Naitik * */ public class Main { static FastReader sc=new FastReader(); static int dp[]; static boolean v[]; // static int mod=998244353;; static int mod=1000000007; static int max; static int bit[]; //st...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
cf18fdc4581853219fadf07059552df3
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; import java.util.*; public class B { static final int INF = (int)1e9+5; public static v...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
e1abe5ed96e3284267fb3ea6818aba01
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class Tes{ static Scanner sc=new Scanner(System.in); static class Pair{ int x; int y; int dist; public Pair(int x,int y,int dist){ this.x=x; this.y=y; this.dist=dist; } } public static voi...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
82ecf0b9d5912612000f8b73d63f4fe7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { StreamTokenizer tokenizer = new StreamTokenizer( n...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
54eb00797c0936a6dbb8261cc00e736f
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.sqrt; import static java.lang.Math.floor; public class topcoder { static void rec(int [][]mat, int i, int j, int n, int m, boolean vis[...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
badd8df52ae7cd662945eab2a687cf1b
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static int find(int i,int j,int n,int m) { int midh=n/2; int midl=m/2; int b1=n,b2=m; if(i>midh) { b1=1; } if(j>midl) { b2=1; } return Math.abs(i-b1)+Math.abs(j-b2); } public static void main(St...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
1126bc92782ed53fd8550276b25f3d8a
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class cf1 { static FastReader x = new FastReader(); static OutputStream outputStream = System.out; static PrintWriter out = new PrintWriter(outputStream); /*---------------------------------------CODE STARTS...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
41e1f22c7e08b0161a9ef43867a7adac
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.InputMismatchEx...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
0746b3145cf2370a1707fc04f98bf972
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class contestb { FastScanner scn; PrintWriter w; PrintStream fs; long MOD = 1000000007; int MAX = 200005; long mul(long x, long y) {long res = x * y; return (res >= MOD ? res % MOD : res);} long power(long x, long y) {if (y < 0) retu...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
7849327e5939ca735f758a3e8a26800e
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class s1 { public static FastScanner scan; public static PrintWriter out; public static void main(String[] args) throws Exception { scan=new FastScanner(System.in); out=new PrintWriter(System.out); // int T=1; int T=scan.nextInt(); while(T-->0) { ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
ecbd40959ab1dbf92ae23a554e6cf14d
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Jan15P2 { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); for (int i = 0; i < t; i++) { int n = sc.nextInt(); int m = sc.nextInt();...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
193db8190111ec8b53b97916ed74b3ef
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
/* Setting up my ambitions Check 'em one at a time, yeah, I made it Now it's time for ignition I'm the start, heat it up They follow, burning up a chain reaction, oh-oh-oh Go fire it up, oh, oh, no Assemble the crowd now, now Line 'em up on the ground No leaving anyone behind */ import static java.lang.Math...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
250469e0029f3116b5025eeed1826c6b
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void bfs(int n,int m){ Queue<int[]> que = new LinkedList<>(); int vis[][] = new int[n][m]; if(n%2==1 && m%2==1){ que.add(new int[]{n/2,m/2}); vis[n/2][m/2]=1; } else if(n%2==1 && m%2==0){ que.add(new int[]{n/2,m/2...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f18e3cc86544e3dcfd65d0e5b7a82633
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
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.Comparator; import java.util.List; import java.util.StringTokenizer; public class Main { static FastReader fr; static int defMod = 1000000007; static in...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
b4d7a76159b10f6d3cc365b89850f727
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class R766B { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in))...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
4da9eca405d2c5fed9c5545215770e75
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class Solve { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
92e663cba72f0ee7d1156ba551098e5a
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(new BufferedInputStream(System.in)); PrintWriter pw = new PrintWriter(System.out); int t= sc.nextInt(); while(t-->0){ ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
255e8649092a9f8fedb4fd7220f98312
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.List; import java.util.Scanner; public class B1627 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); StringBuilder output = new StringBuilder(); for (int t=0; t<T; t++) { int R = in.nextInt()...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
170a87d6ed8f6ca8cd118ccca7cbf5a7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import static java.lang.Math.abs; import static java.lang.Math.min; import static java.lang.System.out; public class pre97 { static class FastReader { BufferedReader br; StringTokenizer...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
d71c2189858f0ef433d2250d3a229888
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-->0){ int n = sc.nextInt(); int m = sc.nextInt(); List<Integer> list = new ArrayList<>(); for(int i = 0;i<n;i++){ f...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
0065679f99dea7c6116858b6d6cbccaf
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Solution { static BufferedReader bf; static PrintWriter out; public static void main (String[] args)throws IOException { bf = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int t = Integer.parse...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
687e08107eb4c6f8fa3493f41279da91
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package CodeForces.RoadMap.Diff1300; import java.util.PriorityQueue; import java.util.Scanner; /** * @author Syed Ali. * @createdAt 02/02/2022, Wednesday, 00:33 */ public class NotSitting { static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int t = sc.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
3c97a85b825fd168cd0f0a893f94100d
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class _1627B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n=sc.nextInt(); int m=sc.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
95297ee46e2ea304f5a9f617d62951da
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// Pratham Gupta // template import java.io.*; import java.util.*; import static java.lang.Math.*; import java.math.*; import static java.lang.System.*; public final class Main { static int mod = 1000000007; static int min_value = Integer.MIN_VALUE; static int max_value = Integer.MAX_VALUE; static Fa...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
695b9fec1007ff65d9ed39a9135648f4
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static class Pair implements Comparable < Pair > { int d; int i; Pair(int d, int i) { this.d = d; this.i = i; } public int compareTo(Pair o) { return this.d -...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
55157951ef599eeffb0a2443bfe43ffc
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class temp { // Let's Go!! -------------> static FastScanner sc; static PrintWriter out; public static void main(String[] args) { sc = new FastScanner(); out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
da376a06b4ef5708854a900849e898b3
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.PriorityQueue; import java.util.StringTokenizer; public class NotSitting { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
418465eb6053fc2b461768ef4ca430cd
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package CodeForces.RoadMap.Diff1300; import java.util.PriorityQueue; import java.util.Scanner; /** * @author Syed Ali. * @createdAt 02/02/2022, Wednesday, 00:33 */ public class NotSitting { static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int t = sc.nextInt(); while(t-- >...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
b45917fbcd9f36f2ed9e63004777a714
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; public class Codeforces { static String ab,b; static class Node { int val; Node left; Node right; public Node(int x) { // TODO Auto-generated constru...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
3e7413c914bc13d18f111c3b37e7d32a
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class cf1627b { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st; int t = Integer.parseInt(br.read...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
4a0bb8cd4327e5b249ae4e16ec468389
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.awt.Container; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import jav...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
4252216204ff8ae39d98f4c6b0862fd0
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class B1627 { static StringBuilder sb; static long mod = (long) (1e9 + 7); static class Pair{ int x,y,d; Pair(int a,int b,int c){ x = a; y = b; d = c; } } static void solve(int m,int n) { ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
6af9ca037981b0f327a67186a99ba9a7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package com.rajan.codeforces.leve_1300; import java.io.*; import java.util.Arrays; public class NotSitting { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter writer = new BufferedWriter(new Ou...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
8ca40ca6f0cad9619087b8d6ba54b57b
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class NotSitting{ public static void main(String[] args) { FastReader fr = new FastReader(); PrintWriter out = new PrintWriter(System.out); Scanner sc= new Scanner (System.in); //Code From Here---- int t =fr.nextI...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
7b14f0b3048ab8c18de356b8bdd74202
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.util.Map.Entry; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class B { public static void ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
8f6d23a052e854ccb2800d011ff9d9a0
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; import java.lang.Math; public final class Solution { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t; t = sc.nextInt(); while(t > 0){ int a, b; a = sc.nextInt(); b = sc.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
b4123bc39b1e2ee7f23960acb4226ee3
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class TestClass { public static void main(String args[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out)); int t=Integer.parseInt(br...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
52b7a8de41e1409c8ea107c093d8c4ba
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; //import static com.sun.tools.javac.jvm.ByteCodes.swap; // ?)(? public class fastTemp { static class Node { int data; Node left, right; Node(int data) { this.data=data; left=right=null; } }; ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
832d2a91387c5720ef87f2b8e50d7876
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for(int t=0;t<T;t++){ solve(sc); } } public static voi...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
7bf3ef89b5f4c6ca946cd46102f63033
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class NotSitting { static int maxDistance(int r, int c, int n, int m) { int[] ans=new int[4]; ans[0]=r+c; ans[1]=r+Math.abs(c-(m-1)); ans[2]=Math.abs(r-(n-1))+c; ans[3]=Math.abs(r-(n-1))+Math.abs(c-(m-1));...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f4232a5417ceeb08eac090f011ed1977
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class MyCpClass{ public static void main(String []args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()....
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
ebdbcc675cf2889d4d51714269e636f8
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; //code by tishrah_ public class _practise { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
b812e82dbe482a25f020d1909e749850
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int T = in.nextInt(); for(int ttt = 1; ttt <= T; ttt++) { int n = in.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
0ca872053d962132250866af86e66e91
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//package codeforces_464_div2; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
6f73a1324faf3de1f3374cb48cb002c7
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; import javax.swing.text.Segment; import java.math.*; import java.math.BigInteger; public final class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static Arra...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
1c970a87d46b53d794a96f51eb3fe977
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//import java.io.IOException; import java.io.*; import java.util.*; public class NotSiting { static InputReader inputReader=new InputReader(System.in); static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static void solve() throws IOException ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
73c20df33902b059a5810dfda0f769ea
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.lang.*; public class StringInput { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
4fbb8d261ebcd13e69dd0f45b5712817
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class NotSitting { public static PrintWriter out; public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(br.readLine()); out=new Print...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
fe36fbd772191541be0b9284967fca58
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int test=sc.nextInt(); while(test-->0){ int n=sc.nextInt(); int m=sc.nextInt(); ArrayList<Integer> al=new ArrayList<>(); for(int i=0;i<n;i++){ for(int j...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
b01e7f0dd49d0896fb5b71811db3fc80
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; public class Solution{ static class Graph{ public static class Vertex{ HashMap<Integer,Integer> nb= new HashMap<>(); // for neighbours of each vertex } public static HashM...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
944bb61fdea565e79c5be59adeced379
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// Created By Jefferson Samuel on 23/08/21 at 2:11 am import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; import static java.lang.Integer.parseInt; import static java.lang.Long.parseL...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
e9eacc3bb90a3694c1e1a8705cb1d3cb
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.*; public class CFB { ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
997cbd695d78fc774a71bb1ab5499feb
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Main { private static LinkedList[] adj; static class Pair { int a; int b; Pair(in...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
97da8ebb87747d858fa106a37a388462
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class ques1 { //HashSet<Integer> hs=new HashSet<>(); //PriorityQueue<Integer> pq=new PriorityQueue<>(); //HashMap<Integer,Integer> hm=new HashMap<>(); //ArrayList<Integer> lt=new ArrayList<>(); static long mod=1000_000_007; public static String...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
8e3528e6bb229e6ff672b28a1b3b61a9
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.Arrays; 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 m = scanner...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
ef804fdf1650e1a94de0495ea279d7d1
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import j...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
cd5026f1939f8564632120c58c284a74
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
//---#ON_MY_WAY--- import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class B { static class pair { int x, y; public pair(int a, int b) { x = a; y = b; } } static FastReader x = new FastReader(); static OutputStream outputStream = System....
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
c5c32fd0a303c3753ded6a28896c52ad
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// package CODECHEF; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class problems { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
9ce4f86ec9723f44ee35efd6b9bf018e
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
// package codeforces; import java.io.*; import java.util.*; public class practice { static FastScanner fs = new FastScanner(); public static void main(String[] args) { int t = 1; t = fs.nextInt(); for(int i=1;i<=t;i++) { solve(t); } } public static void solve(int tt) { int ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f8715d1277fa2fe690b28d204c9b3486
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.*; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.Arrays; public class Main { public static void main(String[] args) { FastInput sc = new FastInput(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
e3caeac5e83084a44d625c2282a8b152
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static class DSU { private int[] parent; private int totalGroup; public DSU(int n) { parent = new int[n]; totalGroup = n; for (int i = 0; i < n; i++) { p...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
4f34770229ab1c92d8b3d2c6ea228113
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces766{ static MyScanner sc = new MyScanner(); static void third(){ int n = sc.nextInt(); HashMap<Integer,Integer> map = new HashMap<>(); for(int i = 1;i<n;i++){ int a = sc.nextInt(); int b = sc....
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
273f93b64405416f31b66d80a8bfbd4f
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.Scanner; import java.util.PriorityQueue; public class b { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); for (int t = 0; t < tc; t++) { int n = sc.nextInt(), m = sc.nextInt(); PriorityQue...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
c7fc0fcfcfd1ca6e2a3b54b5f7e3e778
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.Scanner; public class B1627 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); int[][] arr=new int[n][m]; int max=0...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
d928b470fae8038eeb9c57371f055db2
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; import java.uti...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
f64b621143efa71c32e6950f5a3cf7e4
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Practice { static Scanner scn = new Scanner(System.in); static StringBuilder sb = new StringBuilder(); public static void main(String[] ScoobyDoobyDo) { p = new HashSet<>(); int t = scn.nextInt(); for(int te...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
06776ffe49df06389e7dec20c535f0dc
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws Numbe...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
7bc25581a0553082a8ff3af940cb32af
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class NotSitting { public static PrintWriter out; public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(br.readLine()); out=new Print...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
2a2a451302fa2c2dc68afcd1f24566be
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
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 Sparsh Sanchorawala */ pub...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
efd2697b850349ac5a043ceb63fe5b13
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class a { public static void main(String[] args){ FastScanner sc = new FastScanner(); int t = sc.nextInt(); while(t-- > 0){ int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<Integer> numbers = new Array...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
d7e60ad9dd06abc27aa061d696d2a442
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public final class B { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int T = fs.nextInt(); while(T-- > 0){ int n = fs.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 8
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
0a377c67976e7eb54ef7841ca7226a76
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class CF1627B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in, Standard...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
2d650e5387b31f1a5720e62ac566f656
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class CF1627B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8); int t = sca...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
6ebb51c56d06a07457bb6b0e32cd140f
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.io.*; public class practice { public static void solve() { Reader sc = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int m = sc.nextInt(); ...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
086d254cf7446f3c75a7f1d4779aaba0
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
/** * Surly * 21.09.2022 **/ import java.util.*; import java.math.*; import java.io.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter pr = new PrintWriter(System.out); public static void main (String[] args) throws IOException{ double star...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
c2043eeb15c8a7e786109097e9a6d83d
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class Round766B { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String IMPO...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
6984eff9e66f0767ca7241d916a7ea22
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.io.*; import java.util.*; public class first { public static void main(String[] args) { // System.out.println("hey"); Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t > 0){ int n = sc.nextInt(); int m = sc.n...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
a5f753d3036e852af7dd6c293996d4b4
train_109.jsonl
1642257300
Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a $$$n \times m$$$ grid. The seat in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r, c)$$$, and the distance between two seats $$$(a,b)$$$ and $$$(c,d)$$$ i...
256 megabytes
import java.lang.reflect.Array; import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { public static FastReader cin; public static PrintWriter out; public static void main(String[] args) throws Exception { out = new PrintWriter(new BufferedOutputStream(Syste...
Java
["2\n\n4 3\n\n1 2"]
1 second
["3 3 4 4 4 4 4 4 5 5 5 5 \n1 1"]
NoteOne possible sequence of choices for the first testcase where Tina has $$$k=3$$$ buckets of paints is as follows.Tina paints the seats at positions $$$(1, 2)$$$, $$$(2, 2)$$$, $$$(3, 2)$$$ with pink paint. Rahul chooses the seat at $$$(3, 1)$$$ after which Tina chooses to sit at $$$(1, 3)$$$. Therefore, the distanc...
Java 17
standard input
[ "games", "greedy", "sortings" ]
dc1dc5e5dd17d19760c772739ce244a7
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \cdot m \leq 10^5$$$) — the number of rows ...
1,300
For each test case, output $$$n \cdot m$$$ ordered integers — the distance between Rahul and Tina if both of them act optimally for every $$$k \in [0, n \cdot m - 1]$$$.
standard output
PASSED
8aba655faa0e3f784ff250f18095c3e2
train_109.jsonl
1642257300
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, with edges numbered from $$$1$$$ to $$$n-1$$$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree.A prime tree is a tree where the wei...
256 megabytes
//created by Toufique on 09/08/2022 import java.io.*; import java.util.*; public class NotAssigning { static ArrayList<Integer>[] adj; static ArrayList<Integer> ans; static ArrayList<String> input; static boolean[] vis; static int[] parent; static HashMap<String, Integer> m; ...
Java
["3\n2\n1 2\n4\n1 3\n4 3\n2 1\n7\n1 2\n1 3\n3 4\n3 5\n6 2\n7 2"]
1.5 seconds
["17\n2 5 11\n-1"]
NoteFor the first test case, there are only two paths having one edge each: $$$1 \to 2$$$ and $$$2 \to 1$$$, both having a weight of $$$17$$$, which is prime. The second test case is described in the statement.It can be proven that no such assignment exists for the third test case.
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "number theory", "trees" ]
0639fbeb3a5be67a4c0beeffe8f5d43b
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^5$$$) — the number of vertices in the tree. Then, $$$...
1,400
For each test case, if a valid assignment exists, then print a single line containing $$$n-1$$$ integers $$$a_1, a_2, \dots, a_{n-1}$$$ ($$$1 \leq a_i \le 10^5$$$), where $$$a_i$$$ denotes the weight assigned to the edge numbered $$$i$$$. Otherwise, print $$$-1$$$. If there are multiple solutions, you may print any.
standard output
PASSED
238a3c71e0ffed93ad0f75f37898938e
train_109.jsonl
1642257300
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, with edges numbered from $$$1$$$ to $$$n-1$$$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree.A prime tree is a tree where the wei...
256 megabytes
import java.util.*; import java.io.*; import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.sqrt; import static java.lang.Math.floor; public class topcoder { public static class TreeNode { int val; TreeNode left; TreeNode right; TreeNo...
Java
["3\n2\n1 2\n4\n1 3\n4 3\n2 1\n7\n1 2\n1 3\n3 4\n3 5\n6 2\n7 2"]
1.5 seconds
["17\n2 5 11\n-1"]
NoteFor the first test case, there are only two paths having one edge each: $$$1 \to 2$$$ and $$$2 \to 1$$$, both having a weight of $$$17$$$, which is prime. The second test case is described in the statement.It can be proven that no such assignment exists for the third test case.
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "number theory", "trees" ]
0639fbeb3a5be67a4c0beeffe8f5d43b
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^5$$$) — the number of vertices in the tree. Then, $$$...
1,400
For each test case, if a valid assignment exists, then print a single line containing $$$n-1$$$ integers $$$a_1, a_2, \dots, a_{n-1}$$$ ($$$1 \leq a_i \le 10^5$$$), where $$$a_i$$$ denotes the weight assigned to the edge numbered $$$i$$$. Otherwise, print $$$-1$$$. If there are multiple solutions, you may print any.
standard output
PASSED
f523b17c5fdf1f8bee64ab4db9406643
train_109.jsonl
1642257300
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, with edges numbered from $$$1$$$ to $$$n-1$$$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree.A prime tree is a tree where the wei...
256 megabytes
import java.io.*; import java.lang.*; import java.lang.reflect.Array; import java.util.*; import java.util.concurrent.atomic.LongAccumulator; import javax.management.openmbean.ArrayType; public class Main { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I...
Java
["3\n2\n1 2\n4\n1 3\n4 3\n2 1\n7\n1 2\n1 3\n3 4\n3 5\n6 2\n7 2"]
1.5 seconds
["17\n2 5 11\n-1"]
NoteFor the first test case, there are only two paths having one edge each: $$$1 \to 2$$$ and $$$2 \to 1$$$, both having a weight of $$$17$$$, which is prime. The second test case is described in the statement.It can be proven that no such assignment exists for the third test case.
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "number theory", "trees" ]
0639fbeb3a5be67a4c0beeffe8f5d43b
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^5$$$) — the number of vertices in the tree. Then, $$$...
1,400
For each test case, if a valid assignment exists, then print a single line containing $$$n-1$$$ integers $$$a_1, a_2, \dots, a_{n-1}$$$ ($$$1 \leq a_i \le 10^5$$$), where $$$a_i$$$ denotes the weight assigned to the edge numbered $$$i$$$. Otherwise, print $$$-1$$$. If there are multiple solutions, you may print any.
standard output