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
2b8dc8be92c51beafd70f8e025c3dd8a
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; import javax.lang.model.util.ElementScanner14; public class pavan { static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); long t = sc.ne...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
93b44dfa9a21683cdaabffe40c728659
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.Scanner; import static java.lang.System.out; public class Problem7 { static Scanner scanner = new Scanner(System.in); static void solve() { int n = scanner.nextInt(); out.println(n); for (int i = 1; i<=n; i++) { StringBuilder builder =...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
fb395d8e6a0567f80771e7cf04f1f8ab
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.Scanner; public class SolutionB { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); while (t > 0) { t--; solve(input.nextInt()); } input.close(); } private static void solve(int n) { int[] a = new ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
9dff6391224eaf8055aeab3d8a706b51
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.lang.*; import java.lang.Exception; import java.math.BigInteger; import java.util.*; public class Main { private static final BufferedWriter sout = new BufferedWriter(new OutputStreamWriter(System.out)); private static final double PI = 3.141592653; public static int ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
52f5283cec1bed64270cbe4fea6e7301
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; public class AB { public static void main(String args[]) throws IOException { FastReader sc = new FastReader(); PrintWriter out = new PrintWriter(System.out); int tc, i, j; String s; char p; tc = sc.nextInt();...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
3fe32e4ec9a5ae37b05cdca19132bef2
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import jdk.swing.interop.SwingInterOpUtils; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Codechef { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int t = sc.nextInt(); while(t-...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
866b3fbc76c1c8742f89e0c16c1d04e3
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { var T = readInt(); while (T-- > 0) solveTestCase(); } private void solveTestCase() throws IOException { int n = readInt(); out....
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
ef713b21fd7e6acdaaee8804e4cd5d4c
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.*; import java.io.*; public class B { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader( new InputStreamReader(System.in)); } String next(){ while (st == null || !st.hasMoreElements()){ try{ st ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
31bc7309395f8a97ceaa402740519020
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; public class B { Input in; PrintWriter out; public B() { in = new Input(System.in); out = new PrintWriter(System.out); } public static void main(String[] args) { B solution = new B(); for (int t = solution.in.ne...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
1d338575a397fcd3f9c8240a09cdf142
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
dc9aacfa21749779103a1de09f91dabe
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Codechef { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static PrintWriter pw = new PrintWriter(System.out); private static Scan...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
494fceffe66bea00bce21a96e8181de6
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
//package com.tdorosz._1716; import java.util.Scanner; public class PermutationChain { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); for (int i = 0; i < testCases; i++) { executeTestCase(scanner)...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
afd9928ef7b50eaf29876fa7bbac1451
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class TaskB { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(System.out);...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
765ed9340f0dfb910d235a25d0f9f449
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; public class permchain { public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
6f844840c5a78095f5e93a1c835382e2
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] ar...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
724b4971d2da2f91d0ca1977c93bdb52
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
4111572391af703401728ba9c4881f87
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
/*-------- Author : Ryan Ranaut __Hope is a big word, never lose it__ ----------*/ import java.io.*; import java.util.*; public class Codechef1 { static PrintWriter out = new PrintWriter(System.out); static final int mod = 1_000_000_007; static final long max = (int) (1e18); ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
be0da04e3dc0e60daceddfc88c3b6cf5
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class practice { static FastInput scn; static PrintWriter out; final static int MOD = (int) (1e9 + 7); final static int MAX = Integer.MAX_VALUE; final static int MIN = Integer.MIN_VALUE; // MAIN public static v...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
48622d35db322aeaa925f8c2cf2c125d
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; import static java.lang.System.*; import static java.lang.System.out; import static java.lang.Ma...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
bc56b0d2af22d2c2fc7c22b39872af9c
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.lang.System.*; public class PermutationChain implements Runnable { private final void solution() throws IOException { // InputReader input = new InputReader(new FileReader(System.getenv("INPUT"))); // P...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
ff8c0b884dddfb0a6e5a24f88fb34514
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.*; import java.util.*; public class MainClass{ static class Reader{ private final BufferedReader reader; private StringTokenizer tokenizer; Reader(InputStream input) { this.reader = new BufferedReader(new InputStreamReader(input)); th...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
09228674762a202dffae8cd2d6115807
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.util.Scanner; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; public class codeforces_2022_08_04_B { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
6e233ebb83cb96e6dbc732221c762569
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ public class B { public static void process() throws IOException { int n = sc.nextInt(); System.out.pri...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
633c3d0fb810ddaa8759852c5ff0fbc0
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
// O(NN) import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.HashSet; import java.util.NoSuchElementException; public class Main implements Runnable { public static void main(String[] args) { new T...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
c604f68281a3c657224dd5e85d28483a
train_109.jsonl
1659623700
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once.Let the fixedness of a permutation $$$p$$$ be the number of fixed points in it — the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of the p...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu133B { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["2\n\n2\n\n3"]
2 seconds
["2\n1 2\n2 1\n3\n1 2 3\n3 2 1\n3 1 2"]
null
Java 17
standard input
[ "constructive algorithms", "math" ]
02bdd12987af6e666d4283f075f73725
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 99$$$) — the number of testcases. The only line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the required length of permutations in the chain.
800
For each testcase, first, print the length of a permutation chain $$$k$$$. Then print $$$k$$$ permutations $$$a_1, a_2, \dots, a_k$$$. $$$a_1$$$ should be an identity permutation of length $$$n$$$ ($$$[1, 2, \dots, n]$$$). For each $$$i$$$ from $$$2$$$ to $$$k$$$, $$$a_i$$$ should be obtained by swapping two elements i...
standard output
PASSED
33885f7465a817b282f8f3a0f452c284
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class ybg{ static int [][] ss; static int [][] s; public static void main(String[]args) { PrintWriter d = new PrintWriter(new OutputStreamWriter(System.out)); FastScanner c = new FastScanner(); int a = c.nextInt(); for(int...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
dad97780e4d95f08c01c64fc48cb9d43
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; /* 1 2 0 1 0 1 1 3 0 0 1 4 3 2 */ public class C{ static FastReader sc=null; static int dx[]= {1,0,-1,0},dy[]= {0,1,0,1}; public static void main(String[] args) { sc=new FastReader(); int t=sc.nextInt(); for(int tt=0;tt<t;tt++) { ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
42c5d7094bc1ce11a5397e5351685bae
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class Main02 { static Scanner in = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static StringBuilder res = new StringBuilder(); public static void main(String[] args) { int t = Integer.parseI...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
6cb9bb42be7513c8594c0526e39399bf
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Sol { static Scanner rd = new Scanner(System.in); public static void main(String[] args) { int tt = rd.nextInt(); while (tt-- > 0) { new Solution().solve(); } } static int INF = Integer.MAX_VALUE; ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
51729d147ed9f07dc2ab00c71e64d1a8
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class c { public static void main(String[] args) { FastScanner scan=new FastScanner(); PrintWriter out=new PrintWriter(System.out); /* ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
7952be42af38beda39daf3483cfc0f26
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import jav...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
651e9fcde3a80fbcbfb41aac6623ab22
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import jav...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
40ff1d3f1a9a7506b10959d22ef59a9c
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
/*========================================================================== * AUTHOR: RonWonWon * CREATED: 07.11.2022 17:26:56 /*==========================================================================*/ import java.io.*; import java.util.*; public class C { public static void main(St...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
d87e7c70c7688f1abe0a5773150a14ee
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
139b24cbeca859b4fa2c12d6d4a4504c
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
/* Goal: Become better in CP! Key: Consistency and Discipline Desire: SDE @ Google USA Motto: Do what i Love <=> Love what i do If you don't use your brain 100%, it deteriorates gradually */ import java.util.*; import java.io.*; import java.math.*; public class C { static StringBuffer str...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
26568623430e28d288869edf3c7aefc4
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
/* Goal: Become better in CP! Key: Consistency and Discipline Desire: SDE @ Google USA Motto: Do what i Love <=> Love what i do If you don't use your brain 100%, it deteriorates gradually */ import java.util.*; import java.io.*; import java.math.*; public class C { static StringBuffer str...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
059f3aa30ce74d39b10a4e8508cf6700
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class RobotInAHallway { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int M = io.nextInt(); final long[][] A = { io.nextLongArray(M), io.nextLongArray(M), }; long best = Long...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
37c701f767ec9223e002e5efa40409be
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class RobotInAHallway { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int M = io.nextInt(); final long[][] A = { io.nextLongArray(M), io.nextLongArray(M), }; ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
3cd8853ed04b591ee932aa9e40355736
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int N; static Read s = new Read(); static int sum; static int[][] dir = new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; public static void main(String[] args) throws IOException { int ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
37e132be1a37f17e1ec5cb18e089fa2b
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Main { static Main2 admin = new Main2(); public static void main(String[] args) { admin.start(); } } class Main2 { //---------------------------------INPUT READER-----------------------------------------// publi...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
4fc1e90e21a0c9e33fed20bc6125f0db
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader sc=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static int dx[]={0,0,-1,1},dy[]={-1,1,0,0}; static final double pi=3.1415926536; static long mod=1000000007; // static long mod=998244353; static int ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
5c8d7cb021bf2b7c0ca823111626d4fa
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class CF1{ public static void main(String[] args) { FastScanner sc=new FastScanner(); // hamare saath shree raghunath to kis baat ki chinta......
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
061d54d7776ae241c0feb6e017775cfa
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; public class ACM { private static int m; private static int[][] lock; public static void main(String[] args) { Scanner in = new Scanner(System.in); for (int t = in.nextInt(); t > 0; t--) { m = in.nextInt(); lock = new int[...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
8cc9b6b4f295b07b30ae50c7b94538ba
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import javafx.util.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { static class Reader { final private int BUFFER_SIZE = 1 << 16; ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
3dfb72c92650e36de5163ea7686c0874
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.StringTokenizer; /** * C. Robot in a Hallway */ public class Main { static class FastReader { BufferedReader reader; StringTokenizer tokenizer; FastReader(InputStream stream) { reader = new BufferedReader(new InputStreamRea...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
e1e39539ddfce9b6e3fc0d0feb6a641f
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.StringTokenizer; /** * C. Robot in a Hallway */ public class Main { static class FastReader { BufferedReader reader; StringTokenizer tokenizer; FastReader(InputStream stream) { reader = new BufferedReader(new InputStreamRea...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
4c65191889404c5a566d2786e56e5bc3
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; // res.append("Case #"+(p+1)+": "+hh+" \n"); ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thr...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
9568c1a160740c9065f831ffe740c3ff
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public final class Main { //int 2e9 - long 9e18 static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)}; static...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
6746ad78afada458208ac1cfbcdad2b5
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; public class ACM { private static int m; private static int[][] lock; public static void main(String[] args) { Scanner in = new Scanner(System.in); for (int t = in.nextInt(); t > 0; t--) { m = in.nextInt(); lock = new int[...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
ebd4c559a336fcaf3bdf6bf00d0a8e26
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; public class ACM { private static int m; private static int[][] lock; public static void main(String[] args) { Scanner in = new Scanner(System.in); for (int t = in.nextInt(); t > 0; t--) { m = in.nextInt(); lock = new int[...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
87bccabf6f385e7c25657365b201cc58
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; public class C { static int[][]a,passed,rem,ans; public static void ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
856f783bda1a8893ecc3d7964d94ab13
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); solver.solve(in.nextInt(), in, out); ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
c685df3fa751ba4f4a992de8410288ab
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static boolean useInFile = false; public static boolean useOutFile = false; public static void main(String args[]) throws IOException { InOut inout = new InOut(); Resolver resolver = new Resolver(inout); // ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 8
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
75d7b9755c27f2423332f1930b6dfc9a
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int mod = 998244353; //static int mod = (int)1e9+7; static boolean[] prime = new boolean[1]; static int[][] dir1 = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; static int[][] dir2 = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
5740199a61084497d5921d5744d72381
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
338c8d18f6b3b76871a811560498dc72
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class Main { static ContestScanner sc = new ContestScanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(); static long mod = (long) 1e9 + 7; public static void main(String[] args) ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
1839d6eab97d6ff2c7e71e515bd6c54d
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import j...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
ce6659aa2a0664e1bdfb808c468ea53d
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class TimePass { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); int testCases=Integer.parseInt...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
32cd01f90f79e7b0bd5ecac074e86b7b
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main { //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; public static int cnt; //-----------MyScanner class for faster input---------- public static class MySca...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
fbf9409880c69cc647c099b8043b116d
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class First { public static void main(String[] args) throws Exception{ FastReader f = new FastReader(); StringBuilder str = new StringBuilder(); int cases = f.nextInt(); fo...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
54d72c8a7c2758aa16ce8b24a6c12e61
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Main { static FastScanner sc; static PrintWriter out; public static void main(String[] args) { sc = new FastScanner(System.in); out = new PrintWriter(System.out); int t = 1; if (true) { t = sc.next...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
2b8e6f3e2b159dda56ce636112659ed8
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef {static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buff...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
3858019ad2188967dff5ee2083da2155
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // C. Robot in a Hallway // https://codeforces.com/contest/1716/problem/C // time limit per test 2 seconds; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
00c0083e0f6790f586a90c5b35484d66
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // C. Robot in a Hallway // https://codeforces.com/contest/1716/problem/C // time limit per test 2 seconds; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
c4e44c92e08b29ffb2c12d06aef0be5c
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static Scanner obj = new Scanner(System.in); public static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int len = obj.nextInt(); while (len-- != 0) { int n=obj.nextInt(); int[] a=new int[n...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
a0a9440cde9159cc5068b604b0a453d3
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static Scanner obj = new Scanner(System.in); public static PrintWriter out = new PrintWriter(System.out); public static void debug(int[] a) { for(int i=0;i<a.length;i++) { System.out.print(a[i]+" "); } Syst...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
07ad045917cb6239265eaff4653e3808
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; public class quesC { public static void main(String[] args) throws Exception {; Scanner scn= new Scanner(System.in); int t= scn.nextInt(); while(t-->0){ int n= scn.nextInt(); int[][] arr= new int[2][n]; for(int i=0; i<arr.lengt...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
01215ec271f6edb04d2c765430b265c1
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int N; static Read s = new Read(); static int sum; static int[][] dir = new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; public static void main(String[] args) throws IOException { int ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
3e0011cc53224a1f98473956359c7375
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int t; static int m; static int[][] a; static int[][] sfmax1; // max of a[i][j] - j static int[][] sfmax2; // max of a[i][j] + j static int min; public static void main(String[] args) throws IOException { t = in.iscan(); ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
c99f46f4ea6e2c0a8b6a6fd99e4b8a59
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { int[][] a; int m; public void solve() throws IOException { int t = readInt(); for (int tt = 0; tt < t; tt++) { m = readInt(); a = new int[m][2]; for (int i = 0; ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
c8b817a881b8043b773771e0c17f1e95
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class codeforces_Edu133_C { private static void solve(FastIOAdapter in, PrintWriter out) { int m = in.nextInt(); int[] a1 = in.readArray(m); int...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
d7bf1bcd9ea440d48040fc2ed4355867
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class _1716_C { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int t = Integer.parseInt(in.readLine()); while(t-- > 0) { ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
7821cfc50c821ef201de836c96aa3561
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class Solution extends PrintWriter { void solve() { int t = sc.nextInt(); for(int tc = 1; tc <= t; tc++) { test_case(); } } void test_case() { int m = sc.nextInt(); int[][] ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
759577774f5597932772adee42557b73
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.sort; /* * 11223456 * * */ public class Codeforces { static int max = (int) (2e5) + 5; public static ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
c1ae3af2b5a029126b7c32b70074dbd1
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.security.SecureRandom; import java.util.InputMismatchException; import java.util.Random; import java.util.StringT...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
d565d12d2b29ce6aa2a4edf72097f621
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.io.*; public class codeforce { static boolean multipleTC = true; final static int Mod = 1000000007; final static int Mod2 = 998244353; final double PI = 3.14159265358979323846; int MAX = 1000000007; void pre() throws Exception { } long combination(int n, int r, ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
7f979dfe6d7c799fb57c8724125f3279
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class UWI { //#0.00代表保留两位小数 static DecimalFormat df = new DecimalFormat("#0.00000000"); void solve() { for (int T = ni(); T > 0; T--) go(); } void go() { int n = ni(); int[][] nums...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
8bd23873c167bc44b54fcae27aca65d8
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
3391241206cc8926b4bf49152a57a99d
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
// Problem: C. Robot in a Hallway // Contest: Codeforces - Educational Codeforces Round 133 (Rated for Div. 2) // URL: https://codeforces.com/contest/1716/problem/C // Memory Limit: 256 MB // Time Limit: 2000 ms import java.io.*; import java.util.*; public class Main { static IntReader in; static F...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
efefb489ffcfc6cfdebe3dd5f1cdcfac
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int t = Integer.pa...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 11
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
d0a5f352bc75e3c5b85880518cbd3276
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
// O(NN) import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Random; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "", Run...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 17
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
7cac469e61c29062d26cfc4a60e28630
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.Scanner; public class problem { private static final Scanner sc = new Scanner(System.in); public static void solve() { int m = sc.nextInt(); int [][]a = new int[2][m]; for(int i = 0; i < 2; i++) { for(int j = 0; j < m; j++) a[i][...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 17
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
4710ed0daaa16e16974a322375a99c5d
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.io.*; import java.util.*; public class CF1716C extends PrintWriter { CF1716C() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1716C o = new CF1716C(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; void main() { int t = sc.nextInt()...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 17
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
b70984fc8c3888cbd9abe8c4db145c6b
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu133C { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 17
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
19f20f93280d7290658188d15075e243
train_109.jsonl
1659623700
There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In one second, it can perform either of two actions: move into a cell adjacent...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ public class C { public static void process() throws IOException { int n = sc.nextInt(); int arr[] = ...
Java
["4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0"]
2 seconds
["5\n19\n17\n3"]
null
Java 17
standard input
[ "data structures", "dp", "greedy", "implementation", "ternary search" ]
f9f82c16e4024a207bc7ad80af10c0fe
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$m$$$ ($$$2 \le m \le 2 \cdot 10^5$$$) — the number of columns of the grid. The $$$i$$$-th of the next $$$2$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i...
2,000
For each testcase, print a single integer — the minimum amount of seconds that the robot can take to visit all cells without entering any cell twice or more.
standard output
PASSED
ce1bd4cf519b629d28631d060b00da80
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu133F { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 17
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
142114f6220174d58db8eac3fcae3650
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*cla...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 11
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
0e43fc1f6717031286295e1c7e525500
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*cla...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 11
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
70119cbcf48ced9a83b429d89592f79f
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*cla...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 11
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
98de395b299d635cd44d5876b7e7820e
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*cla...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 11
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
b73d7f50e1b61a8053fc8b587a299676
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*cla...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 11
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
941824e45d7bde7492ca16784734fe0a
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 8
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
ca7eedf7cd81a68d1aa5dcad95b31794
train_109.jsonl
1659623700
There are $$$n$$$ bags, each bag contains $$$m$$$ balls with numbers from $$$1$$$ to $$$m$$$. For every $$$i \in [1, m]$$$, there is exactly one ball with number $$$i$$$ in each bag.You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball $$$1$$$ from the first bag and t...
512 megabytes
// package c1716; // // Educational Codeforces Round 133 (Rated for Div. 2) 2022-08-04 07:35 // F. Bags with Balls // https://codeforces.com/contest/1716/problem/F // time limit per test 3 seconds; memory limit per test 512 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)...
Java
["5\n\n2 3 8\n\n1 1 1\n\n1 5 10\n\n3 7 2000\n\n1337666 42424242 2000"]
3 seconds
["1028\n1\n3\n729229716\n652219904"]
null
Java 8
standard input
[ "combinatorics", "dp", "math", "number theory" ]
fc8381e8c97190749b356f10cf80209e
The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 998244352$$$; $$$1 \le k \le 2000$$$).
2,500
For each test case, print one integer — the sum of $$$F^k$$$ over all possible ways to take $$$n$$$ balls, one from each bag. Since it can be huge, print it modulo $$$998244353$$$.
standard output
PASSED
972f5c03473cf3f8317db0f7858a525e
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.io.*; import java.util.*; public class Div21716E { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = In...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 11
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
ff81f042521c6a51123fcabae6589052
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.io.*; import java.util.*; public class Div21716E { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); ...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 11
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
d3f72abf3cc4f0037276b7df2ccac802
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.util.*; import java.io.*; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; /* Solution Created: 16:30:25 09/08/2022 Custom Competitive programming helper. */ public class Main { static class Node{ l...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 8
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
8f74859d923f067357ef083548c18f33
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.util.*; import java.io.*; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; /* Solution Created: 16:30:25 09/08/2022 Custom Competitive programming helper. */ public class Main { static class Node{ l...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 8
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
6f129fc3a40a9db7574d783cdd9474c5
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.util.*; import java.io.*; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; /* Solution Created: 16:30:25 09/08/2022 Custom Competitive programming helper. */ public class Main { static class Node{ l...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 8
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
2bed998344118f8154a0e4f4c2814046
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.util.*; import java.io.*; public class Template { FastScanner in; PrintWriter out; long[] prefSums; public long sumSeg(int l, int r) { if (l == 0) return prefSums[r]; else return prefSums[r] - prefSums[l - 1]; } public void solve() throws IO...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 17
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output
PASSED
3a29fabef29a65108ada92316f84fcb7
train_109.jsonl
1659623700
You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$$). To process the query, you should do the following: for every $$$i \in [1...
512 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu133E { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1"]
4 seconds
["18\n8\n13"]
NoteTransformation of the array in the example: $$$[-3, 5, -3, 2, 8, -20, 6, -1] \rightarrow [-3, 2, -3, 5, 6, -1, 8, -20] \rightarrow [2, -3, 5, -3, -1, 6, -20, 8] \rightarrow [5, -3, 2, -3, -20, 8, -1, 6]$$$.
Java 17
standard input
[ "bitmasks", "data structures", "dfs and similar", "divide and conquer", "dp" ]
376b293013562d5e004411f42082ce5c
The first line contains one integer $$$n$$$ ($$$1 \le n \le 18$$$). The second line contains $$$2^n$$$ integers $$$a_1, a_2, \dots, a_{2^n}$$$ ($$$-10^9 \le a_i \le 10^9$$$). The third line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$). Then $$$q$$$ lines follow, the $$$i$$$-th of them contains one inte...
2,500
For each query, print one integer — the maximum sum over all contiguous subsegments of the array (including the empty subsegment) after processing the query.
standard output