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 | 3a83ea274ee0db0d28aab2ab3ff5ec45 | train_000.jsonl | 1467219900 | Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindrome... | 256 megabytes | import java.util.*;
public class LovelyPlandrome {
public static void main (String[]args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
StringBuffer b = new StringBuffer(s);
b.reverse();
System.out.print(s+b);
}
} | Java | ["1", "10"] | 1 second | ["11", "1001"] | NoteThe first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001. | Java 8 | standard input | [
"constructive algorithms",
"math"
] | bcf75978c9ef6202293773cf533afadf | The only line of the input contains a single integer n (1 ≤ n ≤ 10100 000). | 1,000 | Print the n-th even-length palindrome number. | standard output | |
PASSED | dc17d2866ed046c44a0085867dd440e6 | train_000.jsonl | 1467219900 | Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindrome... | 256 megabytes | import java.util.*;
import java.lang.*;
public class lovely{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
String s=sc.nextLine();
String a=s;
StringBuffer sb= new StringBuffer(s);
sb.reverse();
System.out.print(a+sb);
}
} | Java | ["1", "10"] | 1 second | ["11", "1001"] | NoteThe first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001. | Java 8 | standard input | [
"constructive algorithms",
"math"
] | bcf75978c9ef6202293773cf533afadf | The only line of the input contains a single integer n (1 ≤ n ≤ 10100 000). | 1,000 | Print the n-th even-length palindrome number. | standard output | |
PASSED | 25be10503efc14f0c8c1f4c4f4b3df43 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
public class Sol{
static int c[];
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int vertices=s.nextInt();
Graph g=new Graph(vertices+1);
int root=0;
c=new int[vertices+1];
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | ac117e0c80db5df7d9d12aa4bfe3cf59 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class test{
static ArrayList<Integer>[] tree;
static boolean[] visited;
static boolean[] disrespect;
static boolean[] delete;
public static void main(... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 9649d09f8aaeae6a10500857d43d742a | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;
public class torem {
static int po[];
static ArrayList<Integer> ar[];
static ArrayList<Integer> anss=ne... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 9f578f99bc711af165bc38556df31481 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static final long mod = (long)Math.pow(10, 9) + 7;
public static void main (String[] args) throws IOException{
FastReader f=new FastReader();
int n = f.nextInt();
ArrayList<Integer>[] e = new ArrayList[n];
for (int i=0;i<n;i... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | cdf483bbb6bac69397762ae0eed0a5a8 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import javafx.util.Pair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class C {
static StringTokenizer st;
static ... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 528fb666e9860008bea58cfa3194cb92 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.util.*;
import java.io.*;
public class CodeForces {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
// int t=s.nextInt();
// while(t-->0){
int n=s.nextInt();
int[] p=new int[n];
int[] c=new int[n];
boolean v[]=new boolean[n];
for(int i=0... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | d95dca40abf52f7e902759ef56abc124 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
static class Node {
int n;
ArrayList<Node> list = new ArrayList();
int val;
Node(int name) {
n = name;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int no... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 0f0b988164ccf8e07ab0c5d057c7ae09 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.io.*;
import java.util.*;
public class C {
public void solve() throws IOException {
int n = nextInt();
ArrayList<Integer>[] g = new ArrayList[n];
for (int i = 0; i < n; i++) {
g[i] = new ArrayList<>();
}
int[] c = new int[n];
int root = 0;
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | ce1b1e2641799ad67b2e6b73b1047b4c | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.IOException;
import java.util.ArrayList;
im... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | bab502ecc298e2028e6dcc7d650ebe2f | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.PriorityQueue;
impo... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 1bd6635486e143dfb708918501483354 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
public class C1143
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int ans[] = new int[t+1];
int p[] = new int[t+1];
int c[] = new int[t+1];
int end = 0,z = 0;
int i,j;
for(i=1;i<=t;i++)
{... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 91ca5096ecc102fdee4a00879d97d2f0 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.ObjectOutputStream.PutField;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.uti... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 918b1ac69c369c47a686e38f52c55f89 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public final class Main{
public static boolean[] prime;
public static final class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new Buffere... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 0398fc83fb61195e550c6f0cb2a95779 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public final class Main{
public static boolean[] prime;
public static final class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new Buffere... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | f91a4b0ba4990cf961f871efd87a22d4 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int n = scn.nextInt();
int[] par = new int[n], arr = new int[n];
for(int i = 0; i < n; i++) {
par[i] = scn.nextInt() - 1;
arr[i] = scn.nextInt();
}
int[]... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 3f94228c139a1b51f7ca91a0065c7d2f | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int n = scn.nextInt();
int[] par = new int[n], arr = new int[n];
for(int i = 0; i < n; i++) {
par[i] = scn.nextInt() - 1;
arr[i] = scn.nextInt();
}
int[]... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 480f671d5080fb1790390b14843cff6e | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Inpu... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 91b4e780deda30a083f7622eb6d91781 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class C {
public static void main(String[] args) throws IOException{
FastReader reader = new FastReader();
int n = reader.nextInt();
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 0ca4d579432d512414f9def07c8d7e8f | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class z71 {
static ArrayList<Integer> adj[];
static TreeSet<Integer> ans = new TreeSet<>();
public static void solve(InputReader in, PrintWriter out) throws Exception {
int n = in.nextInt();
adj = new ArrayList[n+1];
for(int i=0;i<=n;i... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | d0a54c88f6f82d9a18de1bc0ab75d324 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class MainClass
{
public static void main(String args[])throws IOException
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
int p[]=new int[n];
int c[]=new int[n];
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 214fc6638111163857dfe4eb7eea4610 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class MainClass
{
public static void main(String args[])throws IOException
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
int p[]=new int[n];
int c[]=new int[n];
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 8bbfb0516d83c3aebe37a1bff157345c | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class TaskA {
private boolean eof;
private BufferedReader br;
private StringTokenizer st;
private BufferedWriter out;
public static void main(String[] args) throws IOException {
new TaskA().run();
}
private String nextToken() {
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 0843949081c7e30a711aedcd05192526 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class TaskA {
private boolean eof;
private BufferedReader br;
private StringTokenizer st;
private BufferedWriter out;
public static void main(String[] args) throws IOException {
new TaskA().run();
}
private String nextToken() {
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 6bf590f9ac34e1f7df3d0e84690165ea | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes |
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.*;
import java.math.*;
import java.text.*;
public class Queen {
static ArrayList<ArrayList<Integer>> ar = new ArrayList<ArrayList<Integer>>();
static Set<Integer> ans = new HashSet<>();
static void dfs(i... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | ab19df2c306c328e812092770e33609e | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.Scanner;
import java.util.TreeSet;
public class Queen {
public static class Node implements Comparable<Node> {
int c = 0;
int ind = 0;
Node p = null;
TreeSet<Node> child = new TreeSet<Node>();
public void delete() {
for (Node e : this.child) {
e.p = this.p;
}
p = null;
}
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | f53f8f3d01696b628d3b24d296c931e3 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.Scanner;
/**
*
* @author arabtech
*/
public class Nirvana {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] c = new int[n];
int[] p = new int[... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 267149e0676af25b689e691072153ed4 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.io.*;
import java.util.*;
public class Main {
private static Reader fr;
private static OutputStream out;
private stati... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | a11ee9683d57eeb5a486bfe1bd99c30c | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import static java.lang.Math.*;
public class D {
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 4313a2f5e0bb38878081bbac5393eaf5 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Queen549C {
static class Pair {
int respect,index;
public Pair(int index,int respect) {
this.respect= respect;
this.index = index;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.index+"";
}
}
st... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 719f31c718e9f19b084b0226f1e60761 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void initGraph(ArrayList<Integer> graph[]) {
for(int i = 0; i<graph.length; i++) {
graph[i] = new ArrayList<>();
}
}
public static ArrayList<Integer> graph[] = new ArrayList[(int) 1e6];
public static int c[] = new int[(int) 1e6];
p... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 0be0bd0022476d1f8047c26d5f75971e | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;
public class cf1143c {
static int[] tra;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = ... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 7b14b1b72f6426b46e510f6344421042 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
import org.omg.CORBA.Principal;
import java.awt.List;
import java.io.*;
import java.lang.*;
public class graph {
public static long mod = (long) Math.pow(10, 9) + 7;
public static InputReader in = new InputReader(System.in);
public static PrintWriter pw = new PrintWriter(System.out);
public ... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | b3a85f5a7c6024cb53430d8bbd551544 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static TreeSet<Integer> ans=new TreeSet<>();
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine().trim());
int roo... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 18595e9bd66cf6dcb99f1867338de87a | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.LinkedList;
public class C_ {
public static void main(String[] args) throws IOException {
StreamTokenizer in = new StreamTokenizer(new InputStreamReader(System.in));
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 1424b227bdffd6df7d07ea1d356227ab | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 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.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
im... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | a71c4b5feb62bc8889d027f175d99bff | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | // Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
pub... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | e029d026ca23aad98e9ecd7686ae0664 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class GFG {
static ArrayList<Integer> adj[];
static HashMap<Integer,Integer> map;
static PriorityQueue<Integer> pq=new PriorityQueue<>();
static int vis[];
static int p=0;
static void dfs(int i) {
vis[i] = 1;
if((adj[i].size(... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | ab6ea12d12b7509e63f444e2b57a3d59 | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
InputStream inputStream = System.in;
// InputStream inputStream = new FileInputStream(new File("input.txt"));
OutputStream outputStream = System.out;
Input... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 38d2f0abf3deb8a20987117e35a264dd | train_000.jsonl | 1553965800 | You are given a rooted tree with vertices numerated from $$$1$$$ to $$$n$$$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.Ancestors of the vertex $$$i$$$ are all vertices on the path from the root to the vertex $$$i$$$, except the vertex $$$i$$$ itself. The parent of the ver... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int c[] = new int[n + 1];
int p[] = new int[n + 1];
boolean ok[] = new boolean[n + 1];
for (int i = 0; i < n; i++) {
... | Java | ["5\n3 1\n1 1\n-1 0\n2 1\n3 0", "5\n-1 0\n1 1\n1 1\n2 0\n3 0", "8\n2 1\n-1 0\n1 0\n1 1\n1 1\n4 0\n5 1\n7 0"] | 1 second | ["1 2 4", "-1", "5"] | NoteThe deletion process in the first example is as follows (see the picture below, the vertices with $$$c_i=1$$$ are in yellow): first you will delete the vertex $$$1$$$, because it does not respect ancestors and all its children (the vertex $$$2$$$) do not respect it, and $$$1$$$ is the smallest index among such ver... | Java 8 | standard input | [
"dfs and similar",
"trees"
] | 1b975c5a13a2ad528b668a7c68c089f6 | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of vertices in the tree. The next $$$n$$$ lines describe the tree: the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$c_i$$$ ($$$1 \le p_i \le n$$$, $$$0 \le c_i \le 1$$$), where $$$p_i$$$ is the parent of the vertex $$$i$$$,... | 1,400 | In case there is at least one vertex to delete, print the only line containing the indices of the vertices you will delete in the order you delete them. Otherwise print a single integer $$$-1$$$. | standard output | |
PASSED | 6e1592f77f93a5815ef3ba2fb880516d | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.*;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
public static void main(String[... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 7bf3eb4d277dda5bb43b4ce82e984e0e | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class _729_C_RoadToCinema {
static ArrayList<Integer> gs; static int T;
public static void main(String[] args) throws IOException {
int N = readInt(), K = readInt(), M = readInt(); T = readInt();
int cst[] = new int[N+1], cap[] = new int[N+1]; for(int i = 1; i<=N; ... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 3624aa1c9becb1ebd9569745f2792f07 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.*;
import java.util.*;
public class test
{
public static void main(String args[])
{
//System.out.println("Welcome");
inputs in=new inputs(System.in);
int n=in.nextInt(),k=in.nextInt(),
s=in.nextInt(),t=in.nextInt();
car cars[]=new car[n];
... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | d8b4f657d4024ee02e826f7ec1ae4f37 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | /** This is a solution to the problem Road To Cinema (729C) on codeforces.com
*
* Given:
* - n cars with price c_i and fuel tank volume v_i
* - k gas stations along a road of length s, at given positions
* - timelimit t
*
* Fuel stations are free and instant. Each car has two speeds: 2min/km with 1l/km, and 1m... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 6e49d8378c51615042e9fd27f5686b69 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class Solution {
static class Solver {
FastScanner scanner;
PrintWriter out;
List<Integer> result;
Solver() {
scanner = new FastScanner(System.in);
out = new PrintWriter(System.out);
... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 17d972d50d2f930060e74e5e7c3c1ac8 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
public static final String NL = "\n";
public static final String SP = " ";
public void append(StringBuffer sb, int[] arr) {
for (int val: arr) {
sb.append(val);
sb.append(" ");
}
sb.append(NL);
}
public void append(StringBuffer sb, String..... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 698b39bdf99ff8cdbc4597b7af581b4c | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
public static final String NL = "\n";
public static final String SP = " ";
public void append(StringBuffer sb, int[] arr) {
for (int val: arr) {
sb.append(val);
sb.append(" ");
}
sb.append(NL);
}
public void append(StringBuffer sb, String..... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 203cf1b624f0f2158e36f3d92a23d3be | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class D{
public static void main(String[] args) throws Exception{
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
String str = sc.readLine();
StringBuffer myBuf... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | df7f33e2a74173c42fb80f316eea282b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes |
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.*;
public class Third{
static long mod=1000000007;
public static void main(String[] args) throws Exception{
InputReader in = new InputReader(System.in);
PrintW... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | d58ef231653f2592a14068b4589204e2 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import javafx.util.Pair;
import java.io.*;
import java.util.Arrays;
public class Main {
private static myScanner sc;
private static PrintWriter pw;
private static final boolean defaultInAndOutPut = true;
private static final int numberOfTests = 1;
private static final String nameOfInAndOutFile... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 195023272cf0732c8111df89f3e0f919 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int snext() {
... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 5b6c07a676d40527b4cdf1013483bdf6 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Solution {
static boolean bigEnough(int w, int t, int[] distance) {
long time = 0;
for (int aDistance : distance)
if (aDistance > w)
return fals... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 63fb2550bbb89ce1e3899c6797dfecd2 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
public class Codeforcecontest {
int n,k,s,t;
int arr[];
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | a39a1af88e6ce0709a6f65a06d4fd91a | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author cu... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | c0d0f22f3ef81f4df5ac7b4ed3e19b32 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | //package olymp_prog;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
/**
* Created by Максим on 26.12.2016.
*/
public class C729 {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | ac745cd7f4cd1bd6ffac2305a6076a71 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
MyScanner sc = new MyScanner();
int n ... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 94d72b6ad9a309fb78c8d460d53004f1 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class C {
static class Solver{
int n, k, s, t;
int[] g;
Car[] cars;
public void solve(InputReader in, PrintWriter out) {
read(in);
Arrays.sort(cars);
Arrays.sort(g);
int l = 0, r = n-1, m, minVol = -1;
while (l <= r) {
m = (l+r)/2;
if (isG... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 18a264e03e54f98ef23aa2c29dbd5f59 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Arra... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | aab94e9fb9ea41232eca291598cccdd3 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
/**
* @author pvasilyev
* @since 20 Nov 2016
*/
public class C {
public static void main(String[] args) throws IOException {
final BufferedReader reader = n... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 6ea232ab5dc500c6caff45c54886f76b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class RoadToCinema {
static int n, k, s, t;
static int c[], v[], g[];
static boolean flag;
public static void main(String[] args) throws Exception {
Buf... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 004ce8ea158cd5007ee27a10040fd4ff | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import static java.lang.Math.min;
import static java.util.Collections.reverseOrder;
import static java.util.... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 9069f85d32bfe9b64ceb14b3e94e336b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import static java.lang.Math.min;
import static java.util.Collections.sort;
p... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 743eea8a5dedda610c59ff7eb517fa8b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import static java.lang.Math.min;
import static java.util.Collections.reverseOrder;
import static java.util.... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | aab209770736b85077c89f8f3353ddc4 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | /*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 29a4cf150fdd64f1dd991b41590e6939 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.*;
import java.util.*;
public class SolveC {
BufferedReader br;
StringTokenizer st;
PrintWriter out;
String nextToken() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
int nextInt() throws NumberFormatE... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 65227a5fb5fada316ef8d795c44aa31c | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C {
public static void main(String[] args) {
MyScanner in = new MyScanner();
int n = in.nextInt();
int k = in.nextInt();
int ... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | a4dc5ea63c92a48077e086ced0571ff5 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.util.stream.*;
import java.io.*;
import java.math.*;
public class Main {
static boolean FROM_FILE = false;
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
if (FROM_FILE) {
t... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 5762460e27e5e9bc1b816424f80df06b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class lp{
static PrintWriter out = new PrintWriter(System.out);
static long max = 10000000000000l;
static boolean ok(long mid,long s,long t,int g[])
{
int prev=0;
long tt=0;
for(int i=0;i<g.length;i++)
{
long d =g[i]-prev;
if(d>mi... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 89d184253cb1fc211a9e3a37b623118a | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes |
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Main{
public static void main(String[] args) throws FileNotFoundException {
Scanner scanner =new Scanner(System.in);
// Scanner scanner =new Scan... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | b0a9ca879b64af311495fe0d2edc99a5 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class elmovies {
public static BufferedReader ... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 6109bd4d77f72feee0d37d7f2e0156ca | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Road_To_Cinema_CD729C {
static carro lista[];
static int s;
static int t;
static int paradas[];
public static void main(... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 58bd2d6852a0debf38f0c52303505c1b | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class codeforces729C {
public static boolean checkIfPossible(int[] distance,int k,int t,int fuel) {
int time = 0;
for(int i=0;i<=k;i++) {
if(distance[i]>fuel) {
return false;
} else if(fuel>=2*distance[i]){
time+=distance[i];
} else {
time+=(3*dist... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | dc96f172c442ac523b8bf08782344471 | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.io.*;
public class codeforces729C {
public static boolean checkIfPossible(int[] distance,int k,int t,int fuel) {
int time = 0;
for(int i=0;i<=k;i++) {
if(distance[i]>fuel) {
return false;
} else if(fuel>=2*distance[i]){
time+=distance[i];
} else {
time+=(3*dist... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 946d372a95b49cc4311a065bcc7b8bfb | train_000.jsonl | 1479632700 | Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.T... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
public class A {
static class Node implements Comparable<Node>{
long price;
long cap;
public Node(long price, long cap){
this.price=price;
this.cap=cap;
}
public int compare... | Java | ["3 1 8 10\n10 8\n5 7\n11 9\n3", "2 2 10 18\n10 4\n20 6\n5 3"] | 1 second | ["10", "20"] | NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel.... | Java 8 | standard input | [
"binary search",
"sortings",
"greedy"
] | 740a1ee41a5a4c55b505abb277c06b8a | The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts. Each of the next n lines contains two positive... | 1,700 | Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1. | standard output | |
PASSED | 4a1994383c5803d025234c258e1a4815 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class MainClass
{
static boolean ff = false;
public static void main(String[] args)throws IOException
{
Reader in = new Reader();
StringBuilder stringBuilder = new StringBuilder();
int t = in.nextInt();
while (t-- > 0)
{
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 7ba7f187ffe6e19b2e88934e448c45cb | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes |
import java.util.*;
public class CodeforcesContest {
private static long sport(List<Integer>[] graph, int n) {
CycleFinder cycleFinder = new CycleFinder(graph, n);
List<Integer> cycle = cycleFinder.findCycle();
Set<Integer> set = new HashSet<>(cycle);
long ans = 0;
for (I... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 79e2d708829441e5b206664a66d9d948 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes |
import java.io.*;
import java.util.*;
public class A {
static BufferedReader br;
static int cin() throws Exception
{
return Integer.valueOf(br.readLine());
}
static int[] split() throws Exception
{
String[] cmd=br.readLine().split(" ");
int[] ans=new int[cmd.length];
for(int i=0;i<cmd.length;i++)
{
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | b465d4395f083a3e0c2fc647a952c316 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class Ana {
static int n, p[];
static boolean vis[], inCycle[], found;
static ArrayList<Integer>[] graph;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int tt = sc.n... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 7372749b56d286203532a5641e1dd8e2 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
impor... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 6dcd3082b198e9f2de9cef6ecb98744b | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 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.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
public class EX1_8 {
static... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | fc2824ad39d36ad35b151a7bdf9b1ce8 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 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.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
public class EX1_8 {
static... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 98049cce7290e4a3fcdd68c6bb3d32a1 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class E1454 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
ArrayList<Integer>[] adjList = new Arra... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 64adc8d9baa92cb8aaf3fff5e19981a4 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static BufferedReader bf;
public static long[][] dp;
public static void main(String[] args) throws IOException {
bf = new Buffer... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | ccf8769157580b3bc03d95b4a7bd17e8 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
private static FastReader fr = new FastReader();
private static Helper hp = new Helper();
private static StringBuilder result = new StringBuilder();
public static void main(String[] args) {
Task solver = new Task();... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 0cec3f222342c22401cd42e1cb0cbe19 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
private static FastReader fr = new FastReader();
private static Helper hp = new Helper();
private static StringBuilder result = new StringBuilder();
public static void main(String[] args) {
Task solver = new Task();... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | ed50106284de8890746ecece4b656463 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | // Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
// Please name your class Main
public class Main {
//static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
/*static int read() throw... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 8bcce92925f1f00c67ca75f4cf3e23ed | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class CF686e {
static PrintWriter pw;
static class FastReader {
private InputStream mIs;
private byte[] buf = new byte[1024];
private int curChar, numChars;
public FastReader() {
this(System.in);
}
public FastReader(InputStream is) {
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | e266d068b576098e5aca95f99db8bb61 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Collectors;
public class Main {
static FastScanner sc;
static PrintWriter pw;
static final int INF = 1000000000;
public static Integer cycle_end, cycle_st;
public static int[] p;
public static int[] ... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | cc9c2178b74268d968e0aa8fd264d2fa | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class Number_Into_Sequence {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 767a48f15c5c0f110f66c9f2da15ba01 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class Number_Into_Sequence {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 7965bef62bd953d211225066b6ce9a97 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.util.*;
import java.io.*;
public class Number_Into_Sequence {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 8aa9dc1684cd7acf8b2a822db4cf612f | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class CodeFor1 {
public static void main(String[] args) throws IOException {
// InputStream inputStream = new FileInputStream("input.txt");
// OutputS... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 4d96bc533519b93d47f42f51ae3da67b | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
// graph, dfs,bfs, get connected components,iscycle, isbip... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | bececc9a4937cbe4a862802793d1664e | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main extends PrintWriter {
ArrayDeque<Integer>[] adj;
int[][] edges;
boolean[] done;
int[] p;
int dfs1(int u, int p) {
done[u] = true;
for(int e : adj[u]) {
int v = edges[e][0] == u?edges[e][1]:edges... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 16397fe85f09495bbe5acf2871bfd6e4 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcep... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | bace5b5295e2e5c4cb7420c350e03faf | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main {
... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | c18804b6fe02e6fa0fb9060089142d72 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class simplePaths {
public static void main(String[] args) {
FastScanner... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 2fd5f9bbaf272b8bf89518d24124da27 | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class simplePaths {
public static void main(String[] args) {
FastScanner... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output | |
PASSED | 52b531b5712272a9f184f8aaa7ec102a | train_000.jsonl | 1606228500 | You are given an undirected graph consisting of $$$n$$$ vertices and $$$n$$$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.Your task is to calculate the number of simple paths of leng... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
/*
1
3
1 2
2 3
1 3
1
4
1 2
2 3
3 4
4 2
*/
public class E {
public static void... | Java | ["3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3"] | 2 seconds | ["6\n11\n18"] | NoteConsider the second test case of the example. It looks like that:There are $$$11$$$ different simple paths: $$$[1, 2]$$$; $$$[2, 3]$$$; $$$[3, 4]$$$; $$$[2, 4]$$$; $$$[1, 2, 4]$$$; $$$[1, 2, 3]$$$; $$$[2, 3, 4]$$$; $$$[2, 4, 3]$$$; $$$[3, 2, 4]$$$; $$$[1, 2, 3, 4]$$$; $$$[1, 2, 4, 3]$$$. | Java 8 | standard input | [
"combinatorics",
"dfs and similar",
"trees",
"graphs"
] | 1277cf54097813377bf37be445c06e7e | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of vertices (and the number of edges) in the graph. The next $$... | null | For each test case, print one integer: the number of simple paths of length at least $$$1$$$ in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.