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 | 9b295ad778c5b00f8cb8cc561db808ba | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 198b80e0aeed7dcffa569cff4f2a7cce | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int l0 = 0, l1 = 0, r0 = 0, r1 = 0;
int[][] cabz = new int[n][2];
for (int i = 0; i < n; i++) {
for (int k = 0; k < 2; k++) {
cabz[i][k] = sc.nextInt... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 14280a0384e134b2d460883a10dc92a2 | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.util.Scanner;
public class Cupboards {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int left = 0, right = 0;
for (int i = 0 ; i < n ; i++) {
int a = scan.nextInt(), b = scan.nextInt();
if (a == 1)
left++;
if (b == 1)
right... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | becac88c69451dba05fecab393424583 | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | /*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;
public class GFG {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int counta0=0;
int counta1=0;
int countb0=0;
int countb1=0;
while(n-->0) {
... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 563bbc948d2987480618db94e9019384 | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), l = 0, r = 0;
for (int i = 0; i < n; i++) {
l += sc.nextInt();
r += sc.nextInt();
}
System.out.println(Ma... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | f0062f5aa5dcb3956fec72b57041bc19 | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
int... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 412fdc40e57e2ea1f996b1ccd5bf5c1f | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | f9138781c7d4cee55216bfa47d90770d | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.util.*;
public class Cupboards
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int lopen = 0;
int lclosed = 0;
int ropen = 0;
int rclosed = 0;
for(int i=0;i<n;i++)
{
int l = sc.nextInt();
int r = sc.nextInt();
if(l==1)
lcl... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 9f5e416ecd846983e1277a2cab8d47a2 | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes |
import java.util.Scanner;
/**
*
* @author farah
*/
public class AhmadAli {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int sum=0;
int l1=0 , l0=0 , r1=0 , r0=0... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | 9c9bfd8ac33ffe0409f64a47c4a31d2b | train_001.jsonl | 1353857400 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cu... | 256 megabytes | import java.util.Scanner;
/**
* Created: 2/16/2018
*
* @author phil
*/
public class A248_Cupboards {
public static void main(String[] arg) {
Scanner sc = new Scanner(System.in);
int numCupboards = sc.nextInt();
int leftDoorsOpen = 0;
int rightDoorsOpen = 0;
int time = 0;
for (int i=0; i<numCupboar... | Java | ["5\n0 1\n1 0\n0 1\n1 1\n0 1"] | 2 seconds | ["3"] | null | Java 8 | standard input | [
"implementation"
] | 2052b0b4abdcf7d613b56842b1267f60 | The first input line contains a single integer n β the number of cupboards in the kitchen (2ββ€βnββ€β104). Then follow n lines, each containing two integers li and ri (0ββ€βli,βriββ€β1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, ... | 800 | In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | standard output | |
PASSED | d9e221da988139629a9e15bb92cd1472 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
public static class pair{
int x;
int y;
}
public static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
public String next() {
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 18f9799a00b5f8a04e1df4a0b65d9a36 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 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.StringTokenizer;
public class q4 {
public static void main(String[] args) {
FastReader s = new FastReader();
int n = ... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 4866cecd8f30dbc85287c8bf1680f8b3 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 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.Stack;
import java.util.StringTokenizer;
public class q4 {
public static void main(String[] args) {
FastReader s = new Fas... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 8030a2a9ad17dea7965b0ae8e2ed8ab8 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Pair_of_Topics
{
public static void main (String[] args) throws java.lang.Exception
{
solve();
}
static void solve()throws java.lang.Exception
{ // 2 pointer approach
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Inte... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | d138f4b0c1bbb495740511b69d139496 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Pair_of_Topics {
public static void main(String[] args) throws java.lang.Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine()),a[]=new int[n],b[]=new int[n];
StringT... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 9087e3c6d64e6d0f2f025d3ddda7060f | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Ran... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 25fb00d74c8f08e06e895069537cfc16 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.*;
import java.util.*;
public class R627D {
public static void main(String[] args) {
JS scan = new JS();
//ai+aj > bi+bj
//aj has to be at least (bi-ai)+1 greater than bj
int n = scan.nextInt();
Integer[] prefix = new Integer[n];
int[] a = new int[n];
int[] b= new int[n];
long ans =0;
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 7eaa1b94d67b616fe334a908e4bf6397 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class PairTopics {
static int[] sums;
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.par... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | a18e5db8fee06f427fbc9b7f207e9ef3 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
public class codeforc {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
Integer[] a = new Integer[n];
Integer[] b = new Integer[n];
for (int i = 0; i < n; i++) {
a[i] = s.nextInt();
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 0e59322f9357adab509c89a318ef1de7 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
arr=new long[m];
arr2=new long[m];
arr3=new long[m];
for (int i = 0; i < m; i++) {
arr[i]=sc.nextInt();
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | dd17763e36323cc35d8d65467c154d45 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
public class pair {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Integer n = sc.nextInt();
Integer a[] = new Integer[n], b[] = new Integer[n], d[] = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = sc.nextInt();
for (int i = 0; i < n; i++)
b[i] = s... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 085fa443145704aca0f84fb408d8d2c5 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
Integer[] arr1 = new Integer[t];
for (int i = 0; i < t; i++) {
arr1[i] = sc.nextInt();
}
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | ab471aaf0e3931d66bdab9ed86c5f124 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Main
{
public static long ans(int a[],int b[],int n){
ArrayList<Integer> c=new ArrayList<>();
for(int i=0;i<n;i++){
c.add(a[i]-b[... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 63b5fe653749387362436b89ec2a098e | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | //ARNAV KUMAR MANDAL//
//XYPHER//
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ConcurrentH... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 0cdbfd735b9b9a66a938461ebbc9d8ca | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.util.*;
import java.io.*;
public class D1324 {
static int[] array;
public static boolean check(int a, int b) {
return a + b > 0;
}
public static int search(int start, int end, int x) {
while(start < end) {
int mid = (start + end) / 2;
if(check(x, array[mid])) {
end = mid;
} else ... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 3b28d63eea32b624126655ac94b4c0e7 | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
public class four {
class inputreader{
private InputStream stream;
private int curchar;
private int numchars;
private byte[]arr=new byte[2048];
public inputreader() {
stream=System.in... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 8ea5d5dde618d137a7d18416b027e4ea | train_001.jsonl | 1584018300 | The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
Integer[] a = new Integer[n];
Integer[] b = new Integer[n];
for (int i = 0; i < n; i ++)
... | Java | ["5\n4 8 2 6 2\n4 5 4 1 3", "4\n1 3 2 4\n1 3 2 4"] | 2 seconds | ["7", "0"] | null | Java 8 | standard input | [
"data structures",
"two pointers",
"binary search",
"sortings"
] | e25b247975660c5005bd4da7afd38a56 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) β the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line o... | 1,400 | Print one integer β the number of good pairs of topic. | standard output | |
PASSED | 8a8d1439d16fa735217649755a897b7e | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | // package Graphs;
import javafx.util.Pair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class TimofeyAndTree {
public static void main(String[] args)throws IOException {
BufferedReader br=new BufferedReader(new InputStreamR... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 0a730536a4ec55a7a7d5fc9ffab8b348 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 1a638c527c176059d80c4632c7852e4c | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExceptio... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 5645f50f2fd7e030480b0268e422fa80 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class TimofeyTree {
public static void main(String[] args) {
InputStream in = System.in;
InputReader scan = new InputReade... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 36c75e7801e183cfb3ed59185811206c | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | d9d2cefa1cfd48138bd7da49fd4ae83a | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
public class CF_763A {
static FastScanner sc = new FastScanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
new CF_763A().... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 69ee4f537003effc5ca29d1a4578e190 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | // package codeforces1;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.*;
import java.math.*;
import java.text.*;
public class A395 {
static InputReader in = new InputReader(System.in);
static OutputWriter out = new OutputWriter(System.out);
static boole... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 002c17d207e66f83dffe702cc5d7d712 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
public class Solution implements Runnable {
Buffere... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 41ff33fa6e365cedf269c720df56242a | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.*;
import java.io.*;
public class tree{
public static class Pair{
int x;
int y;
public Pair(int a , int b){
x = a;
y = b;
}
}
... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 683298641b801b5b307b864d185997f1 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.text.*;
public class b286 {
public static void main(String[] args) throws Exception {
//new FileInputStream("input.txt");
//new FileOutputStream("output.txt")
InputReader in = new InputReader(System.in);
OutputWriter out = new Output... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 098e80105da75c3dffe6e5493580ef20 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Arr... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 8eae1376237ae3d5af7edcc4b3fa282f | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes |
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Havr... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 27e9acb507d392ee3eea922ec670022a | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
public static void main (String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] temp=br.readLine().trim().split(" ");
int V=Integer.parseInt(temp[0]);
ArrayList<ArrayList<Integer>>... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | c8b6843811c34e3da01a8d2f918fc0b5 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception ... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | ca3d534fcae8a8a991a75725040dbea3 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.Scanner;
import java.util.ArrayList;
public class Main{
static boolean dfs(int parent,ArrayList<Integer> arr[],boolean visited[],int color[]){
int sourceColor=color[parent];
ArrayList<Integer> list=arr[parent];
visited[parent]=true;
for(int i=0;i<list.s... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | ee2d36aa79158b40cb51855a0b201174 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Bereza {
private static class Edge{
int x;
int y;
public Edge(int u, int v){
x=u;
y=v;
}
public boolean contains(int ... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 24690bb968732e256eae9f9e3fa9ccd4 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;
public class practise {
static final int N = 100010;
static int[] c = new int[N];
static int[] u = new int[N*2];
static int[] v = new int[N*2];
static int m;
static ArrayList<ArrayList<Integer> > lk = new ArrayLis... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | bc9a1d99d406b48c16345271e9fe4ebf | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.math.*;
/**
* Buil... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | c33a24a09b9d8eee773f79ecc9dc0a33 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | //package solution;
import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;
import java.awt.Point;
public final class Solution {
BufferedReader br;
StringTokenizer stk;
public static void main(String[] args) throws Exception {
new Thread(null, new Runnable() {
@O... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 31c67a5d4fcbd68f99a60a814baa6a1e | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | //package practice;
import java.util.*;
import java.io.*;
public class Practice {
public static void main(String args[])
{
InputReader in=new InputReader(System.in);
int n=in.nextInt();
int[] a=new int[n+1];
int[] b=new int[n+1];
int[] color=new int[n+1];
for(int i=1... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | d5e363460195247a5301587f530f8cbb | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class Java763A {
private static int n;
private static int u[];
private static int v[];
private static int parent[];
private static int size[];
private static int color[];
public static void main(String[] args) {
Scanner ... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 978e2e72860349bcf46cedf70f33ce94 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes |
/**
* Date: 12 Nov, 2018
* Link:
*
* @author Prasad-Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 0ed61694292a3cccd5851f00d70af820 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class _763A {
static ArrayList<Integer> adj[];
static int n,c[];
static boolean vis[];
static boolean check(int i,int value)
{
vis[i] = true;
ArrayList<Integer> child = adj[i];
boolean flag = true;
for(Integer j : child)
{
if(vis[j])
co... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 6db3dd808613a655b469767b6ffe8089 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class ssta3 {
static PrintWriter out;
static BufferedReader in;
static StringTokenizer st;
public static void main(String[] args) throws FileNotFoundException {
//out = new PrintWriter("test.out");
... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 6cd2846e2e11d02ca7b34e68a691c044 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | /* / οΎοΎβ β β β β β β β β β β β γ
/ )\β β β β β β β β β β β β Y
(β β | ( Ν‘Β° ΝΚ Ν‘Β°οΌβ β(β γ
(β οΎβ Y βγ½-γ __οΌ
| _β qγ| γq |/
(β γΌ '_δΊΊ`γΌ οΎ
β |\ οΏ£ _δΊΊ'彑οΎ
β )\β β qβ β /
β β (\β #β /
β /β β β /α½£====================D-
/β β β /β \ \β β \
( (β )β β β β ) ).β )
(β β )β β β β β ( | /
|β /β β β β β β | /
[_] β β β β β [___] */
// Main Code at the Bottom
import ... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 5c91149535f0e4114dedcbecd91a5ce7 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
public class A {
public static void main(String[] args){
FastScannerA sc = new FastScannerA(System.in);
int V = sc.nextInt();
Verte... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 3d0943496a8c975116bbb10e1c56d406 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes |
import java.util.*;
import java.io.*;
public class A
{
public static void main(String[] args) throws Exception
{
PrintWriter out = new PrintWriter(System.out);
new A(new FastScanner(System.in), out);
out.close();
}
public A(FastScanner in, PrintWriter out)
{
int N = in.nextInt(... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | ef24770a82486a4b5fce3155c61d2859 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.*;
public class Contest395_1A {
static class pair
{
public int a, b;
public pair(int x, int y) { a=x; b=y;}
public boolean in(int n) { return (n == a || n == b); }
}
public static void main(String[] werwerwea)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<pa... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 59024b09a9f7841cc031f68112e38126 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 7df6875a22009c9454f06a2826a77a06 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class icpc
{
public static void main(String[] args) throws IOException
{
Reader in = new Reader();
//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = in.nextInt();
ArrayL... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 8971288ee84e02bd25f748ca0752adc2 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.util.*;
import javafx.scene.Parent;
import java.io.*;
import java.math.BigInteger;
public class Solution {
private static int[] deg , color;
private static boolean[] vis;
private static ArrayList<Integer>[] v;
public static void run(InputReader in ,PrintWriter out){
int n = in.nextInt();... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 3bc5578795f2da88b944d7062dc6f27e | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class CandidateCode {
static ArrayList<Integer> adj[];
static int col[];
public static void main(String[] args) throws IOException {
FastReader sc = new FastRead... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 3a1e0210987f8fd08aba517acecf3830 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
private final static Random rnd = new Random();
final static long INF = Long.MAX_VALUE;
boolean checkIndex(int index, int size) {
return (0 <= in... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | df83ad9631a4395a92d82a4950546b91 | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.awt.Point;
import java.io.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Tests {
static Scanner in = new Scanner();
static PrintWriter out = new PrintWriter(System.out);
static ArrayList<Integer>[] tree... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | d596a0b17e18c83f584bf6dafcc5691e | train_001.jsonl | 1486042500 | Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList... | Java | ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"] | 2 seconds | ["YES\n2", "YES\n2", "NO"] | null | Java 8 | standard input | [
"dp",
"graphs",
"dsu",
"implementation",
"dfs and similar",
"trees"
] | aaca5d07795a42ecab210327c1cf6be9 | The first line contains single integer n (2ββ€βnββ€β105)Β β the number of vertices in the tree. Each of the next nβ-β1 lines contains two integers u and v (1ββ€βu,βvββ€βn, uββ βv), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1,βc2,β..... | 1,600 | Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. | standard output | |
PASSED | 9838a34a0d5007cde1463663bec56c0f | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class SolutionA{
public static void main(String[] args){
new SolutionA().run();
}
void solve(){
int n = in.nextInt();
int m = in.nextInt();
double ans = 0.0;
int a[] = in.nextIntArray(n);
for(int i = 0; i < m; i++){
int st = in.nextI... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | a2f3bff6e9e73918baca3f9024e73f57 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C444A {
FastScanner in;
PrintWriter out;
void solve() {
int n = in.nextInt();
int m = in.nextInt();
int[] a = new int[n + 1];
for (int i = 1; i <= n; i++) {
a[i] = in.nextInt();
}
int x,y,z;
dou... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 2a725f311130a6249927df92985f2e29 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.util.*;
import java.io.*;
public class A{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new A();
out.flush(); out.close();
}
A(){
solve();
}
... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 8c8bf0a5c15afcf0bcca4b505d237b54 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main
{
public static void main(String args[]) throws FileNotFoundException, IOException
{
//Scanner in =new Scanner(new FileReader("input.txt"));
//PrintWriter out = new PrintWriter(new FileWrit... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | dd18d0044ee2d922191d4fb18bc6e15d | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main
{
public static void main(String args[]) throws FileNotFoundException, IOException
{
//Scanner in =new Scanner(new FileReader("input.txt"));
//PrintWriter out = new PrintWriter(new FileWrit... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 683a561654294e6fce1b922136d393ae | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF444A extends PrintWriter {
CF444A() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF444A o = new CF444A(); o.main(); o.flush();
}
void main() {
int n = sc.nextInt();
int m... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 2598d96fa9bbdb1e543d83fb17705952 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 4df65f24ef691b8fffa6becbb43ea2f6 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;
public class C {
static BufferedReader br;
static PrintWriter pw;
stat... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 8940e7e8d08b5f01e6b506135cba6a41 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
/**
*... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 93270b2f5df41b7a6f5e6f661259c578 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public ... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 8892d2a73bee65945fedfd9bf8b02326 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | // package Round254;
/**
* Created by ankurverma1994
* My code is awesome!
*/
import java.io.*;
import java.util.*;
import java.math.*;
public class DZYLovesPhysics {
final int mod = (int) 1e9 + 7;
final double eps = 1e-6;
final double pi = Math.PI;
final long inf = Long.MAX_VALUE / 2;
//-----... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 97c816bb74f11a4ba26b5f40025e073e | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
public class R254_D1_A {
private static class Edge {
double from;
double to;
double weight;
public Edge(double from, double to, double weight) {
this.from = from;
this.to = to;
this.weight = weight;
}
}
publi... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 699b9321807857edab10e6d53be9146f | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.reflect.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(out... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | e52e05542e092b370026db9d93db2758 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.util.*;
public class N3 {
static int n;
static int dist[][];
static int node[];
static boolean isok[];
static boolean used[];
static int V, E;
static int VI[];
static int EI[];
public static void main(String[] args) {
// TODO Auto-generated method stub
S... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 757c90a88faf5a8da960d65e80356260 | train_001.jsonl | 1404651900 | DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class G {
BufferedReader in;
PrintWriter out;
StringTokenizer tok;
void init() {
try {
in = new BufferedReader(new FileReader("input.t... | Java | ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"] | 1 second | ["0.000000000000000", "3.000000000000000", "2.965517241379311"] | NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal. | Java 8 | standard input | [
"greedy",
"math"
] | ba4304e79d85d13c12233bcbcce6d0a6 | The first line contains two space-separated integers nΒ (1ββ€βnββ€β500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xiΒ (1ββ€βxiββ€β106), where xi represents the value of the i-th node. Consider the graph nodes are numbered ... | 1,600 | Output a real number denoting the answer, with an absolute or relative error of at most 10β-β9. | standard output | |
PASSED | 4d85362e68c304311611e1755cacf533 | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.util.HashMap;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Map;
import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Tre... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | a5bbe3c3c0e06f76b0fce5ce3663ff76 | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Collections.*;
import static java.lang.Math.*;
import static java.lang.Math.min;
import static java.util.Arrays.*;
import static java.math.BigInteger.*;
public class Main{
void run(){
Locale.setDefault(Locale.US);
... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | f430d98bba7ac7eca73560a7b8ac0cbe | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.io.*;
import java.util.*;
public class PrECardboardBox {
public static void main(String[] args) throws IOException {
new PrECardboardBox().run();
}
BufferedReader in;
PrintWriter out;
StringTokenizer st;
String nextToken() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st =... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | f189fe28dc5818a9aba41f9ed08434f0 | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
Task solver = ... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | 112c19dfdb8f40121e70113aeb04a7c7 | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.io.*;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Random;
public class cf436E {
public static void solve(Input in, PrintWriter out) throws IOException {
int n = in.nextInt();
int w = in.nextInt();
final int[] a = new int[n];
final int[]... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | 176b1d0c4daf8361ee257194f6a8db8f | train_001.jsonl | 1402673400 | Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels. Imagine that you are playing Cut the Rope for... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main{
static int n,w;
static Node[][] input;
static TreeSet<Node> tm1;
static TreeSet<Node> tm2;
static int[] res;
public static void main(String[]... | Java | ["2 3\n1 2\n1 2", "5 3\n10 20\n5 10\n10 20\n6 9\n25 30"] | 5 seconds | ["3\n12", "14\n01020"] | NoteIn the first test sample, answer 21 is also assumed correct. | Java 8 | standard input | [
"data structures",
"greedy"
] | a4b9ad2c4980bd7ebe23acb4c37680df | The first line contains two integers n and w (1ββ€βnββ€β3Β·105;Β 1ββ€βwββ€β2n) β the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1ββ€βaiβ<βbiββ€β109) β the attributes of the i-th level. | 2,600 | In the first line print integer t β the minimum time you need to open the next box. In the next line, print n digits without spaces β the description of the optimal scenario: if you need to pass the i-th level for one star, the i-th digit should equal 1; if you need to pass the i-th level for two stars, the i-th d... | standard output | |
PASSED | 8989a21134a31b566b363fab13b50722 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.*;
public class P520D {
final static long MOD = 1_000_000_009L;
final static int MIN_VALUE = -1_000_000_000 - 1;
final static int MAX_VALUE = +1_000_000_000 + 1;
TreeSet<Cube> cubes = new TreeSet<Cube>(new Comparator<Cube>()... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | d777a150a25a43504c2b64bb94de0105 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.*;
public class P520D {
final static long MOD = 1_000_000_009L;
final static int MIN_VALUE = -1_000_000_000 - 1;
final static int MAX_VALUE = +1_000_000_000 + 1;
int m;
TreeSet<Cube> cubes = new TreeSet<Cube>();
TreeSet<... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | ff11317ac3f8571a21056df7cf265587 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;
/**
* @author Don Li
*/
public class Cubes {
static final int MOD = (int) (1e9 + 9)... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 69f9d314fa29a360ba8a66d6dcd1e66e | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 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.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class _520D {
static final int MOD ... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 9b854d914053812b8cf2c12c04ad634b | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main extends PrintWriter {
BufferedReader br;
StringTokenizer stok;
final Random rand = new Random(31);
final int inf = (int) 1e9;
final long linf = (long) 1e18;
final int mod = inf + 7;
class Cube {
int x, y;
int v;
... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | fde201ae682c87597a67a14fa094269f | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;
publ... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 2fca1865d81de7a1b398dc598fc3928c | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.SortedSet;
import java.util.AbstractSet;
import java.util.InputMismatchException;
import java.util.Random;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Map;
import jav... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | d22eca498e7809848efb3c4f2ce2b879 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.awt.*;
import java.util.*;
import java.util.List;
public class Problem {
static int[] dx = {-1, 0, 1};
static HashMap<Point, Cube> allCubes = new HashMap<>();
static TreeSet<Cube> openCubes = new TreeSet<>();
static ArrayList<Long> numbers = new ArrayList<>();
static List<Cube> getCu... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | c6cb5fb3f2985390f9fee11496fbe7d3 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.util.*;
public class D {
int m;
Map<Coordinate, Integer> cubeByCoordinate = new HashMap<Coordinate, Integer>();
Coordinate[] coordinateByCube;
TreeSet<Integer> removable = new TreeSet<Integer>();
long res;
void solve() {
Scanner sc = new Scanner(System.in);
m = sc.nextInt();
coordinateByCube... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 91d5a8ca41710c8970756c5edf05d083 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Cubes {
private static final long MOD = 1000000009L;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(Sy... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | b8db969e302fd040bb5565a6749d7f6f | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Cubes {
private static final int[] dx = new int[]{ -1, 0, 1 };
private static final long MOD = 1000000009L;
private static HashMap<Cube, Integer> cubeToValue;
public static vo... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 23fca513efd27da1ae94f1550e6f3b74 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Map;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 6bf2053aac336ce3efa2b6d5d9e21799 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class CF295B {
int[] row;
int[] column;
TreeSet<Integer> removable = new TreeSet<>();
TreeMap<int[], Integer> position = new TreeMap<>(
... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 8d8322b97ce0c154ef4c846c6a9cabe4 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class Main
{
public static void main(String[] args)
{
Cubes c=new Cubes();
c.begin();
}
}
class Cubes
{
private int nCubes;
private Map<String,Cube> cubesMap;
private List<Cube> mCubes;
private static BigInteger mod=new BigInteger("10000... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 2cbb56e0702a5bf1a76e33f8d0058f18 | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int MOD = 1000000009;
// After writing solution, quick scan for:
// array out of bounds
// special cases e.g. n=1?
//
// Big numbers arithmetic bugs:
// int overflow
// sorting, or tak... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | d5612df19fe0aa50ce908ac53a342a4c | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.ReadOnlyBufferException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashS... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output | |
PASSED | 134bd2a23d572a07902c7bfe5839d41f | train_001.jsonl | 1425279600 | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and mβ-β1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 256 megabytes | import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class B {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
... | Java | ["3\n2 1\n1 0\n0 1", "5\n0 0\n0 1\n0 2\n0 3\n0 4"] | 3 seconds | ["19", "2930"] | null | Java 8 | standard input | [
"implementation",
"greedy",
"games"
] | 9f36d49541e6dd7082e37416cdb1949c | The first line contains number m (2ββ€βmββ€β105). The following m lines contain the coordinates of the cubes xi,βyi (β-β109ββ€βxiββ€β109, 0ββ€βyiββ€β109) in ascending order of numbers written on them. It is guaranteed that the original figure is stable. No two cubes occupy the same place. | 2,100 | In the only line print the answer to the problem. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.