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 | a70bf0e56974f5bc05e96c188180abc6 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
public class DirectionalIncrease {
public static void main(String[] args) throws IOException {
BufferedR... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 0f702cbed8fd399141cf1e48816d9fa3 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.util.*;
public class SelectionSort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
boolean ans = true, checkCycleComplete = false;
long su... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 7d49b96ac13442eb64519009991b64f9 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 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();
... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | e1b09043c550cf408e1a7137dc8b86ab | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int nt = sc.nextInt();
for(int f=0;f<nt;f++)
{
int n = sc.nextInt();
long s = 0;
boolean ok=true;
... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | b9fc65037072e36532beda8193d55161 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
//SOLUTION BEGIN
void pre() throws Exception{}
void solve(int TC) throws Exception {
int N = ni();
long[] A = new long[N];
for(int i = 0; i< N; i++)A[i] = nl();
boolean f = true;
... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 45367efa7019b2023c937d935c46758b | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static FastReader sc=new FastReader();
static final Random random=new Random();
static long mod=1000000007L;
static HashMap<String,Integer>map=new HashMap<>();
public static void main(String args[]) throws IOException {
... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 1ad5e79fa5de9e2f73f0373e85f8c179 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.io.*;
import java.util.*;
public class Q1693A {
static int mod = (int) (1e9 + 7);
static void solve() {
int n = i();
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = l();
}
int lastNonZeroELem = n - 1;
while (... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | edb6ac40a868a9190608e36306306106 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solution {
static class FastReader {
private final BufferedReader br;
private StringTokenizer st;
public FastReader() {
br = ne... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 8b9cc4594429584a5f99652f5c285887 | train_109.jsonl | 1655390100 | We have an array of length $$$n$$$. Initially, each element is equal to $$$0$$$ and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently o... | 256 megabytes | /*
I am dead inside
Do you like NCT, sKz, BTS?
5 4 3 2 1 Moonwalk
Imma knock it down like domino
Is this what you want? Is this what you want?
Let's ttalkbocky about that :()
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class x1693A
{
public static void main(String... | Java | ["7\n2\n1 0\n4\n2 -1 -1 0\n4\n1 -4 3 0\n4\n1 -1 1 -1\n5\n1 2 3 4 -10\n7\n2 -1 1 -2 0 0 0\n1\n0"] | 1 second | ["No\nYes\nNo\nNo\nYes\nYes\nYes"] | NoteIn the first test case we can obtain the array after some operations, but the pointer won't be on the first element.One way of obtaining the array in the second test case is shown below.$$$\langle \underline{0}, 0, 0, 0\rangle \to \langle 1, \underline{0}, 0, 0 \rangle \to \langle \underline{1}, -1, 0, 0\rangle \to... | Java 11 | standard input | [
"greedy"
] | 9f0ffcbd0ce62a365a1ecbb4a2c1de3e | The first line contains a single integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1\le n\le 2 \cdot 10^5)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$... | 1,300 | For each test case, print "Yes" (without quotes) if it's possible to obtain $$$a$$$ after some operations, and "No" (without quotes) otherwise. You can output "Yes" and "No" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response). | standard output | |
PASSED | 662a7abe722cc109442e92049b3c48a8 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 81e4ec5cfaa05e43489160ea41b82fd4 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 5510e681b6bc001bad79f8dea96e3dd4 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 263ef39da37ad28674ede736cd6040ce | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 179ccbb4a22001deee8f64001b896eff | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.function.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
no... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 989dffb83cf350896b6ba55a3a9bdd3d | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.function.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
no... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 169b2b9ef9336df0359dcc063caeda9f | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | f586974c596d942f47e9c88f2cb663e3 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 7b4395768cb7acd9a7d8c90514d0d103 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 1de36f249755bc3be7066c2f619a0764 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 6858a60377399a2119460a318e30471b | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.List;
import java.util.*;
public class FakePlasticTrees {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
int testCases = sc.nextInt();
for(int t=0; t<testCases; t++) {
int n = sc.nextInt();
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | c4b8ed5032767be9bffed505ff5ca11c | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
public class c731{
pu... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 6467680fc5fed90c4e9a85d6ef11b080 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
public class c731{
pu... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 7d62790738e084d2e4ab4c3134e6f37f | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.util.*;
public class Test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-->0) {
int n = sc.nextInt();
List<List<Integer>> adj = new ArrayList<>();
for(int i=0;i<=n;i++) adj.add(new ArrayList<>());... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 8c1c2b9db11a904ed54cceb9f1e66555 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.util.*;
public class Test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-->0) {
int n = sc.nextInt();
List<List<Integer>> adj = new ArrayList<>();
for(int i=0;i<=n;i++) adj.add(new ArrayList<>());
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 2d90e93128eb0c83a24923caf8259071 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.util.*;
public class Test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-->0) {
int n = sc.nextInt();
List<List<Integer>> adj = new ArrayList<>();
for(int i=0;i<=n;i++) adj.add(new ArrayList<>());... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 2af4203634874ba2490683f71ac23f6b | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //import java.io.*;
//import java.util.ArrayList;
//import java.util.Arrays;
//
//public class Codeforces
//{
// public static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
// public static BufferedWriter write = new BufferedWriter(new OutputStreamWriter(System.out));
//
// ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 346d43a56cc06d0314d13e4ba3d48a12 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | /*
I am dead inside
Do you like NCT, sKz, BTS?
5 4 3 2 1 Moonwalk
Imma knock it down like domino
Is this what you want? Is this what you want?
Let's ttalkbocky about that :()
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class x1693B
{
static int[][] edges;
pub... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 40c43fe4a19150ca5b2d3b25b2e8092f | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new Main(), "", 256 * (1L << 20)).start();
}
public ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 6562c9b4578664515527ae4baf63dd36 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
//import org.graalvm.compiler.core.common.Fields.ObjectTransformer;
import java.math.*;
import java.math.BigInteger;
public final class A
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 4c670cee5e0776e7a11ccff77c58011a | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
int t = cin.nextInt();
while (t-->0) {
solve();
}
cin.close();
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 82ca141c856647c985bee8a1fd7d62b1 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class fake_PlasticTrees {
static int ans;
static ArrayList<ArrayList<Integer>> adj;
static long[] dp;
public static void dfs(int v,int[] l, int[] r) {
long sum = 0;
for(int i=0;adj.get(v).size()>i;i++) {
dfs... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 041839184b7541f513bbf379ea672426 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | /* || श्री राम समर्थ ||
|| जय जय रघुवीर समर्थ ||
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;
import static java.util.Arrays.sort;
/*
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 05d61f6954ec7bde539b8dfbb74c3cc6 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static int I(String s) { return Integer.parseInt(s); }
static int N = (int)2e5 + 10;
static String[] ins;
static int n;
static int[] l;
static int[] r;
static int[] p;
static long[] dp;
static List[] graph;
static int res;
static Buffe... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 778d0529e2cfa6a726be4d474a5dd740 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.HashSet;
import java.util.Set;
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();
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | a2c47239b0230efde84cbe434e27fd22 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 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\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | ea8a2d0745680789cb4bb6eb31fc76ea | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
public static PrintWriter out;
static ArrayList<ArrayList<Integer>>al;
static int ans;
static int min[];
static int max[];
public static void main(String[] args)throws IOException {
JS sc=new JS();
out = new PrintWriter(System.... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | de4b94afd8e9b789e5c80b293fdf6461 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees{
static long mod = 1000000007L;
static MyScanner sc = new MyScanner();
static int ans;
static void solve() {
ans = 0;
int n = sc.nextInt();
ArrayList<ArrayList<Integer>> tree = new ArrayList<>();
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | d634c928db128b01cacd9c9949a166d7 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 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 A {
static StringBuffer str=n... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 70559097c9bf871ee9884bbb2ac42d5c | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class R800D1B {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream input;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
input = new Dat... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 0ea23a63e9b5616fd4182edb59abfd0f | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //package kg.my_algorithms.Codeforces;
//import static kg.my_algorithms.Mathematics.*;
import java.io.*;
import java.util.*;
public class Solution {
private static long moves = 0;
public static void main(String[] args) throws IOException {
FastReader fr = new FastReader();
Buffered... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 94528cd2e1081b9b88655d697f419b12 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.util.*;
import java.io.*;
// cd C:\Users\Lenovo\Desktop\New
//ArrayList<Integer> a=new ArrayList<>();
//List<Integer> lis=new ArrayList<>();
//StringBuilder ans = new StringBuilder();
//HashMap<Integer,Integer> map=new HashMap<>();
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | ba80f549ac6d8a1a3ab119c3ba940e1a | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new Main(), "", 256 * (1L << 20)).start();
}
public ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | a5c3332a77967be69007035e233d0853 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.util.Comparator.*;
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();
Resolv... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | b9863b5528e8159296ce81bb030a3b53 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //make sure to make new file!
import java.io.*;
import java.util.*;
public class B800{
public static ArrayList<ArrayList<Integer>> adj;
public static int[] p;
public static long[] l;
public static long[] r;
public static int answer;
public static void main(String[] args)throw... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | ed625f0aeaa8cca469e0ab6fc1ec03cb | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
public class B {
public static void mai... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 203c8c1ac60f5c0281263722deeb0f45 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class FakePlasticTrees {
public static void main(String[] args) throws IOException {
Reader in = new Reader();
PrintWriter out = new PrintWriter(System.out);
int T = in.nextInt();
for (int t = 0; t < T; t++) {
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 8 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | c4fce26a444166b7dcee60153b57525b | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.util.Scanner;
import java.util.ArrayList;
public class Q1693B {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner k = new Scanner(System.in);
int t = k.nextInt();
for(int i=1; i<=t; i++)
{
int n = k.nextInt();
in... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | b1739eaab3553e3f490ab92b5b415176 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static AReader scan = new AReader();
static int N = 200010;
static int[] h = new int[N];
static int[] e = new int[N];
static int[] ne = new int[N];
sta... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | c25e82a125aab913f62718ee6cdfd917 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static AReader scan = new AReader();
static int N = 200010;
static int[] h = new int[N];
static int[] e = new int[N];
static int[] ne = new int[N];
sta... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 938a0bc3bb6ecce5d1708613b6a030bd | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class FakePlasticTrees {
static int MAXN = 1123456;
static boolean[] prime = new boolean[MAXN];
static boolean[] used = new boolean[MAXN];
public static void seive() ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 57e59b5fd16f727f909f36d5f641d4c5 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Solution {
static class FastReader {
private final BufferedReader br;
private StringTokenizer st... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | a90894329497beb886101231259e937e | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static ArrayList<Integer>[] adj;
static int[] left;
static int[] right;
static int answer;
public static void main(String[] args) throws IOException {
Reader in = new Reader();
PrintWriter out = new PrintWriter(System.out);
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 7545d008d9e42657dbcf274886aca88a | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.lang.Math;
import java.util.*;
import java.util.regex.Pattern;
import javax.swing.text.DefaultStyledDocument.ElementSpec;
public final class Solution {
private static class FastScanner {
private final int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
priv... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | f381381c0f8c3ec3061eec956abca393 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //package kg.my_algorithms.Codeforces;
//import static kg.my_algorithms.Mathematics.*;
import java.io.*;
import java.util.*;
public class Solution {
private static long moves = 0;
public static void main(String[] args) throws IOException {
FastReader fr = new FastReader();
Buffered... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 8492aaf757784bd395bfaabd2f46badb | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //package kg.my_algorithms.Codeforces;
//import static kg.my_algorithms.Mathematics.*;
import java.io.*;
import java.util.*;
public class Solution {
private static long moves = 0;
public static void main(String[] args) throws IOException {
FastReader fr = new FastReader();
Buffered... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | c2e74b66679a4290efde9d32bea5682b | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;
public class D {
{
MULTI_TEST = true;
FILE_NAME = "";
NEED_FILE_IO = false;
INF = (long) 1e18;
} // fields
static ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 364b5a1f77ff1a21c904b63385843bd2 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 95343c4a2a93ec174758560491bdd784 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes |
import java.util.*;
public class faketree {
public static long ans = 0;
public static int N = 2 * 100000 + 10;
public static List<List<Integer>> tree;
public static int[] l = new int[N], r = new int[N];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextI... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | dabb4c7f4ff4b525c8525653f2308794 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
/*
getOrDefault
valueOf
toCharArray()
System.out.println();
*/
public class Solution{
p... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | b453e1882c9a80d723843d32978a90df | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.util.*;
public class FakeTree {
public static long ans = 0;
public static int N = 2 * 100000 + 10;
public static List<List<Integer>> tree;
public static int[] l = new int[N], r = new int[N];
public static long dfs(int node) {
long s = 0;
for (int child: tree.get(node)) ... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 8d630eb05f58bcf73fd69b032156cba2 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
//SOLUTION BEGIN
void pre() throws Exception{}
void solve(int TC) throws Exception {
int N = ni();
int[] from = new int[N-1], to = new int[N-1];
for(int i = 0; i< N-1; i++){
from[i] =... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 11 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 3352bb8912dc13aa6fb348a5e63236ba | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class R800D1B {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream input;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
input = new Dat... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 17 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 03cf3d95cb426761505f965088166760 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class R800D1B {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream input;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
input = new DataI... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 17 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 40a3f66a38ffd8af7e858631255a4206 | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class FakePlasticTrees {
private static final int START_TEST_CASE = 1;
public static void solveCase(FastIO io, int testCase) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 17 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | a82468be84e4d07069d9fb0f137d009f | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | /*
* Author Name: Raj Kumar
* IDE: IntelliJ IDEA Ultimate Edition
* JDK: 18 version
* Date: 07-Jul-22
*/
import java.io.*;
import java.util.*;
public class R800D1B {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream input;
priva... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 17 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | 83b47c24d76545dd094290d26546c83a | train_109.jsonl | 1655390100 | We are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is the vertex $$$1$$$ and the parent of the vertex $$$v$$$ is $$$p_v$$$.There is a number written on each vertex, initially all numbers are equal to $$$0$$$. Let's denote the number written on the vertex $$$... | 256 megabytes | //package kg.my_algorithms.Codeforces;
//import static kg.my_algorithms.Mathematics.*;
import java.io.*;
import java.util.*;
public class Solution {
private static long moves = 0;
public static void main(String[] args) throws IOException {
FastReader fr = new FastReader();
Buffered... | Java | ["4\n\n2\n\n1\n\n1 5\n\n2 9\n\n3\n\n1 1\n\n4 5\n\n2 4\n\n6 10\n\n4\n\n1 2 1\n\n6 9\n\n5 6\n\n4 5\n\n2 4\n\n5\n\n1 2 3 4\n\n5 5\n\n4 4\n\n3 3\n\n2 2\n\n1 1"] | 1 second | ["1\n2\n2\n5"] | NoteIn the first test case, we can achieve the goal with a single operation: choose $$$v = 2$$$ and $$$c = [1, 2]$$$, resulting in $$$a_1 = 1, a_2 = 2$$$.In the second test case, we can achieve the goal with two operations: first, choose $$$v = 2$$$ and $$$c = [3, 3]$$$, resulting in $$$a_1 = 3, a_2 = 3, a_3 = 0$$$. Th... | Java 17 | standard input | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | 130fdf010c228564611a380b6dd37a34 | The first line contains an integer $$$t$$$ $$$(1\le t\le 1000)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 2 \cdot 10^5)$$$ — the number of the vertices in the tree. The second line of each test case contain... | 1,700 | For each test case output the minimum number of operations needed. | standard output | |
PASSED | a88089f304622afa7f01605ce221a51b | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 8 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | 845c6d4ad576e3bc10fac497ba68e80f | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner inp = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
inp.close();
}
private static void ... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 8 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | 9d6ab9645a634a063a0f9a6058918104 | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner inp = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
inp.close();
}
private static v... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 8 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | 4bd0b3b4b382ef5d79d2165b98da91e3 | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner inp = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
inp.close();
}
private static void solve() {
int n = inp.nextInt();
... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 8 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | 2c58ea5601a17db9601aab9023f8b15d | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 8 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | c245c796db5d95b23f9c657a780faf79 | train_109.jsonl | 1655390100 | Let's call an array $$$a$$$ of $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ Decinc if $$$a$$$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $$$a = [3, 2, 4, 1, 5]$$$, we can remove the decreasing subsequence $$$[a_1, a_4]$$$ from $$$a$$$ and obtain $$$a = [2, 4, 5... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner inp = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
inp.close();
}
private static void ... | Java | ["3\n2 3 1", "6\n4 5 2 6 1 3", "10\n7 10 1 8 3 9 2 4 6 5"] | 2 seconds | ["6", "19", "39"] | NoteIn the first sample, all subarrays are Decinc.In the second sample, all subarrays except $$$p[1 \ldots 6]$$$ and $$$p[2 \ldots 6]$$$ are Decinc. | Java 11 | standard input | [
"brute force",
"data structures",
"divide and conquer",
"dp",
"greedy"
] | 669a34bfb07b82cfed8abccd8ab25f1e | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are distinct) — elements of the permutation. | 2,800 | Output the number of pairs of integers $$$(l, r)$$$ such that $$$p[l \ldots r]$$$ (the subarray of $$$p$$$ from $$$l$$$ to $$$r$$$) is a Decinc array. $$$(1 \le l \le r \le n)$$$ | standard output | |
PASSED | 387dab107b13e3f167d2c03fe919c771 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.*;
import java.util.*;
public class GayAf {
public static void main(String args[]) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader in = new BufferedReader(new FileReader("Input.in"));
StringTokenizer st = new S... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | c3a4994671e76628be27d724cdbabd2a | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Better {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
int ... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 03a759a31b35b903d3d37ffcea086bb5 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.*;
import java.util.*;
public class AmShZ {
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 4d46892be3bbe2ddceaeee7c7db3f766 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | ad8aa5a231379bf82a166e9741ed1051 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.util.Comparator.*;
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();
Resolv... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 8bb780a67fedf3f9c2836ff9613e7029 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | /*
I am dead inside
Do you like NCT, sKz, BTS?
5 4 3 2 1 Moonwalk
Imma knock it down like domino
Is this what you want? Is this what you want?
Let's ttalkbocky about that :()
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class x1693C
{
static final int INF = Integer... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 8d533a6ac9004a01d605d6f4ef5ae9b1 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run() {
work();
out.flush();
}
long mod=1000000007;
long g... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 664e798db24bec4be7c9f7f39b19b2c0 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 9be3b99a425a88bcaaaea14f12c1ed81 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 5e24d9f9ee3f8d0f26e264cabd81366c | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | /* || श्री राम समर्थ ||
|| जय जय रघुवीर समर्थ ||
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;
import static java.util.Arrays.sort;
/*
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 6360af0d619dc338342520f370599765 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
/*
Set of ... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 8 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 5e9d1a826ca5725ab458ac345e88f385 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
/*
getOrDefault
valueOf
char[] arr=st.nextToken().toCharArray();
System.out.println();
List<Integer> l... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 989ae2930bbb57104ecc0ae57f868d8d | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.util.*;
public class Main {
static class Node implements Comparable<Node> {
int n, cost;
public Node(int n, int cost) {
this.n = n;
this.cost = cost;
}
public int compareTo(Node o) {
return Integer.compare(cost, o.cost);
}
}
public static void main(String[] argv) {
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 92b03ccb24d948a9f8d059aa16e0615c | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.util.*;
public class Main {
static class Node implements Comparable<Node> {
int n, cost;
public Node(int n, int cost) {
this.n = n;
this.cost = cost;
}
public int compareTo(Node o) {
return Integer.compare(cost, o.cost);
}
}
public static void main(String[] argv) {
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 83bcc200594351de870768f8101192f0 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.util.*;
public class Main {
static class Node implements Comparable<Node> {
int n, cost;
public Node(int n, int cost) {
this.n = n;
this.cost = cost;
}
public int compareTo(Node o) {
return Integer.compare(cost, o.cost);
}
}
public static void main(String[] argv) {
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 116b6921576a22db7a92c7f230b7ec26 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
int n = cin.nextInt();
int m = cin.nextInt();
int[] block = new int[n];
int[] ans = new int[n];
fo... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 39030e5a5685ea50809bc686f5fb5e40 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class KeshiSearch {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextIn... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 76e5a68d3cc9534c2aa521002409dbeb | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | /*
* Author Name: Raj Kumar
* IDE: IntelliJ IDEA Ultimate Edition
* JDK: 18 version
* Date: 07-Jul-22
*/
import java.io.InputStreamReader;
import java.util.*;
public class KeshiSearch {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] ... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 17 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 5e8679ff3b30d0f29a508db206a2f2e7 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.InputStreamReader;
import java.util.*;
public class Main {
static Scanner cin = new Scanner(new InputStreamReader(System.in));
public static void main(String[] args) {
solve();
cin.close();
}
private static void solve() {
int n = cin.nextInt();
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 11 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 68520f9582adfc5da1146709662bac44 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Solution {
static class FastReader {
private final BufferedReader br;
private StringTokenizer st;
FastReader() {
br = new BufferedReader(
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 11 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | b2ba25742614de8a0271c590cf98c1c9 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.io.IOException;
import java.util.AbstractC... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 11 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 595c2b0863b00ca8de262fd178183a81 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 256 megabytes | import java.util.*;
public class JSA {
static class Node implements Comparable<Node> {
int n, cost;
public Node(int n, int cost) {
this.n = n;
this.cost = cost;
}
public int compareTo(Node o) {
return Integer.compare(cost, o.cost);
}
}
public static void main(String[] argv) {
... | Java | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 11 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | caed8aa6bc40893017169e91972964b6 | train_109.jsonl | 1655390100 | AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $$$n$$$ cities in Italy indexed from $$$1$$$ to $$$n$$$ and $$$m$$$ directed roads indexed from $$$1$$$ to $$$m$$$. Initially, Keshi is located in the city $$$1$$$ and wants to go to AmShZ's house in the city $$$n$$$. Since Keshi doesn't know t... | 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 | ["2 1\n1 2", "4 4\n1 2\n1 4\n2 4\n1 4", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1"] | 2 seconds | ["1", "2", "4"] | NoteIn the first sample, it's enough for AmShZ to send the second type of message.In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $$$1$$$ will be city $$$4$$$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.It's also... | Java 11 | standard input | [
"graphs",
"greedy",
"shortest paths"
] | 1a83878ec600c87e74b48d6fdda89d4e | The first line of the input contains two integers $$$n$$$ and $$$m$$$ $$$(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$$$ — the number of cities and roads correspondingly. The $$$i$$$-th line of the following $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ $$$(1 \le v_i , u_i \le n,v_i \neq u_i)$$$,... | 2,300 | Output the smallest possible integer $$$d$$$ to make sure that AmShZ and Keshi will see each other after at most $$$d$$$ days. | standard output | |
PASSED | 4d58c4e90232802f9f4101acad3cf93a | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /*
TO LEARN
2-euler tour
*/
/*
TO SOLVE
codeforces 722 kavi on pairing duty
*/
/*
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 11 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 958f6bc456e74adfd4ea3dd04df895d0 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class B{
static int[] dx={-1,1,0,0};
static int[] dy={0,0,1,-1};
static FastReader scan=new FastReader();
public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
static ArrayList<Pair>es;
static Linked... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 11 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 36f9edc4b7159cba8b95b81ec00e2d87 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public final class C {
public static void main(String[] args) {
final FastScanner fs = new FastScanner();
fi... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 11 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 56130ebf928e03a57f83a87a1a794dd6 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public final class C1 {
public static void main(String[] args) {
final FastScanner fs = new FastScanner();
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 11 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 76746a9a12aaec73079ac70008ae5006 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
//@author->.....future_me......//
//..............Learning.........//
/*Compete against yourself*/
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;
public class C {
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
static... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 11 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.