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
eaa8e695d95246b3f312eea00ac892c7
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class TheClosestPair { static int mod = 1000000007; static long L_INF = (1L << 60L); static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
fb997123fc453862886bcb94d32c04f5
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.awt.Point; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class Mainclass { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n,k; n=scan.nextInt(); k=scan.nextInt(); int[] arr=new int[n]; int tot=(n*(n-1))/2...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
1ac200bf32dd45622038f7391ae0f956
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class A311 { public static long mod = 1000000007; public static long INF = (1L << 60); static Fast...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
847b081c90b803ce2df5daac555a2776
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
0fe4654478df78013bae804e2adbe5a1
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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 k = in.nextInt(); if( k >= n * (n - 1)/2) { out.println("no solution"); return; } int cnt = 10000; for(int i...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
520d75ff8237bd064f4e3681de4a30a4
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
// package may2020; import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class C { public static void main(String[] args) throws IOException { FastReader scn = new FastReader(); OutputStream out = new BufferedOutputStream(System.out); int n = scn.nextInt(),k = scn.nextInt(); i...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
dc8fcb3ebd8ad63a200bc3a7dfb62746
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; publ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
d50dd394500dac62238393c244b04509
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Tas...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
2d92ebc7bc0f7dac2b3cc4276e05e2b3
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.FileInputStream; import java.util.ArrayList; import java.io.Wri...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
6210882a7c7ffdd3ffba5065bd753186
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { public static void main(String[] args) thro...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
a613336f8b0418aa42081984fbf3b76f
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
/* [ ( ^ _ ^ ) ] */ import java.io.*; import java.util.*; public class test { int INF = (int)1e9; long MOD = 1000000007; void solve(InputReader in, PrintWriter out) throws IOException { int n = in.nextInt(); int k = in.nextInt(); int x = n * (n-1) / 2; if(k>=x) { ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
5e035c98206066c047bf804fc1987ff4
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
ced1773243d0a660c44b22bda09052d3
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
1d632b5f8b7e76a45e07ac138c1b42ae
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; public class R185qATheClosestPair { public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); long x[] = new long[n]; long y[] = new long[n]; ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
d311afec306215143eef1f9076321941
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) 1e18; final static String IO = "_std"; void solve...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
685c99ba13be239f69d77c3a7b7add57
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
480824a2aa6da1911332cbe0e81d1492
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
622c097fc8954695781e83fe48824b75
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; public class RookBishopKing { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k= sc.nextInt(); int tle = n*(n-1)/2; if (tle<=k){ System.out.println("no solution"); ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
c7996fee4efbbb50dcb7defc716234f7
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.StringTokenizer; import java.lang.*; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; import java.util.TreeMap; import java.util.TreeSet; public cla...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
3839ebe1c3dfc42d396c33ffc789f821
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.text.DecimalFormat; import java.lang.Math; import ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
46ef12b6330bbb11a4ac4ccc15a8c6e0
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; public class TheClosestPair { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int k = cin.nextInt(); int a = n * (n - 1) / 2; if (a <= k) { System.out.println("no solution"); } else...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
f15c667291750a001cc60bf3f15783fd
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
d760a635771f5f3170ff62ea3a7bc3c8
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class TheClosestPair { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static void...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
d5da6ffc61cc632f7de0ca8c7c06a6f9
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.InputMismatchException; public class Main { IIO io; Main(IIO io) {...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
92cbb803f03caf74de2c8824ccd96aa6
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
/* * 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 dipankar12 */ import java.io.*; import java.util.*; public class r185a { public static void main(String args[])...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
bb396560b15df72cbe8c65c997d0f8ba
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; /** * Created by hama_du on 15/07/31. */ public class A { public static void main(String[] args) { InputReader in = new InputReader(System.in); Pri...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
761fd0b023ecbd99eb8183db0cf39804
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class GFG { public static void main (String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); if(n*(n-1)/2 > k) { for(int i=0;i<n;i++) System.out...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
408c344e47f4e279b1ec342f3c4ebe2d
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc =...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
ff9797fe3cc29609ef07e399ff863495
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static long mod=((long)1e9)+7;//toString public static int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);} public static long pow_mod(long x,long y){long res=1;x=x%mod;while(y > 0){if((y & 1)==1)res=(res * x)%mod;y=y>>1...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
a179b85b86e6941dc162f2b9a5a7186d
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; public final class closest_pair { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(); public static void main(St...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
69d76ff573d0f40cfc5c2907d35c22ea
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; int[] dx = {0, -1, 0, 1}; int[] dy = {1, 0, -1, 0}; void solve() throws IOException {...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
2f3fdd89027126664ff462646b596b8d
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.Scanner; public class TheclosetPair { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); long k = input.nextLong(); long p = n*(n-1)/2; if(k>=p){ System.out.println("no solution"); ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
de117b95c05dc1c3d921691176c00f8d
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (nu...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
a4ffdfb4ccf08303e2e5e44e7e23ed22
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; public class practice { public static void main(String[] args) { Scanner scn=new Scanner(System.in); int n=scn.nextInt(); int k=scn.nextInt(); if(k>=(n*(n-1)/2)){ System.out.println("no solution"); } else{ for(int i=0;i<n;i++){ System.out.println("0 "+i); } } } }
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
621f994e4c51c1751f98967380ffd7ea
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
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 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
6dc213e4af5b5e21d964f1812a1d2978
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.Scanner; public class TheClosestPath { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int tot = (n * (n-1))/2; int k = sc.nextInt(); StringBuilder sb = new StringBuilder(); if(k < tot) { for(int i = 0; i < n; i++) { ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
32e0ba7d62f6852c2324a4d08cc51563
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.awt.Point; import java.util.*; import java.io.*; import static java.lang.Math.*; public class PracticeProblem { /* * This FastReader code is taken from GeeksForGeeks.com * https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/ * * The article was written by Rishab...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
ed5b45c3094f28a667731e61dd4d08b5
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
// package Practice.CF312; import java.util.Scanner; public class CF312C { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); if(k >= ((n-1)*n)/2){ System.out.println("no solution"); }else{ ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 8
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
050d6c7a8124a9441c16295285d3e995
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class C { public static void main(String[] args) throws IOException { InputReader in = new InputReader(); long n = in.nextInt(); long k = in.nextLong();...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
47bd6ee6b50a1c080722b2bf31368ce0
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = Sys...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
f1afd6fa849b3d4b6b3828f03a3ff56b
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main (String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] input = in.readLine().split(" "); int n = Integer....
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
2a3712fc039bfc69383c7478ecc01daa
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main implements Runnable { private void solve() throws IOException { int n = nextInt(); int k = nextInt(); long[] x = new long[n]; long[] y ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
8b2a53420166f50fa30fea8667d9de9f
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; import java.io.*; public class C312 { class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public InputReader() throws FileNotF...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
c5f6d3cb3850f87b2273c504a631adf8
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; public class cf311a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int max = (n*n-n)/2; if(max <= k) System.out.println("no solution"); else for(int i=0; i<n; i++) System.out.println(0+...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
4f29c5e1dd6eca4477fc8c982ae50cb6
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class A implements Runnable { public void run() { long startTime = System.nanoTime(); int n = nextInt(); int k = nextInt(); if (n * (n - 1) / 2 > k) { for (int i = 0; i < n; i++) { println...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
efb0d11aa72266f224eb6af138dc5513
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class ProblemA { public static void main(String[] args) { OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); Application solver = new Application(); solver.solve(System.in, out);...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
1af13c16405816b4913673e11bf29d43
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamRead...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
34042a7802083daccd6a09de265e10df
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; import java.io.*; public class Contest185div1A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int p = n * (n - 1)/2; if(p <= k) { System.out.println("no solution"); ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
aaf06bdd1242f66830234898c4fdb0ce
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; public class A { void solve() throws IOException { in("__std"); out("__std"); int n = readInt(); int k = readInt(); if (n * (n - 1) / 2 > k) { for (int y = 0; y < n; ++y) { println("0 " + y); } ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
f4a0f01ce2e713a1d248a5aa3d463fa1
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int max = n * (n - 1) / 2; if (max <= k) System.out.println("no solution"); else { ...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
871094de463158ebaac8b9ffe7d45a50
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.io.*; import java.util.*; public class Main { // static Scanner in; static PrintWriter out; static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;} // static BufferedReader in; public static void main(String[] args) throws Exception { // in = new Scanner(S...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
bae948ad377a626552c8cadd2368a1bb
train_001.jsonl
1369582200
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between w...
256 megabytes
import java.util.*; import java.io.*; public class a { static long mod = 1000000007; public static void main(String[] args) throws IOException { //Scanner input = new Scanner(new File("input.txt")); //PrintWriter out = new PrintWriter(new File("output.txt")); input.init(System.in); PrintWriter out = ne...
Java
["4 3", "2 100"]
2 seconds
["0 0\n0 1\n1 0\n1 1", "no solution"]
null
Java 6
standard input
[ "constructive algorithms", "implementation" ]
a7846e4ae1f3fa5051fab9139a25539c
A single line which contains two space-separated integers n and k (2 ≀ n ≀ 2000, 1 ≀ k ≀ 109).
1,300
If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≀ 109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|, |y...
standard output
PASSED
6628d208c32d411ee6eb1cc115e94c52
train_001.jsonl
1594996500
You are given a tree (connected graph without cycles) consisting of $$$n$$$ vertices. The tree is unrooted β€” it is just a connected undirected graph without cycles.In one move, you can choose exactly $$$k$$$ leaves (leaf is such a vertex that is connected to only one another vertex) connected to the same vertex and rem...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; ...
Java
["4\n8 3\n1 2\n1 5\n7 6\n6 8\n3 1\n6 4\n6 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n4 5\n3 6\n7 4\n1 2\n1 4\n5 1\n1 2\n2 3\n4 3\n5 3"]
2 seconds
["2\n3\n3\n4"]
NoteThe picture corresponding to the first test case of the example:There you can remove vertices $$$2$$$, $$$5$$$ and $$$3$$$ during the first move and vertices $$$1$$$, $$$7$$$ and $$$4$$$ during the second move.The picture corresponding to the second test case of the example:There you can remove vertices $$$7$$$, $$...
Java 8
standard input
[ "data structures", "implementation", "greedy", "trees" ]
3581b3a6bf7b122b49c481535491399d
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β€” the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$1 \le k &lt; n$$$) β€” the number of vertices in the tree and ...
2,300
For each test case, print the answer β€” the maximum number of moves you can perform if you remove leaves optimally.
standard output
PASSED
84fc814a7c2e3e6763cf59a4ac8372f5
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public final class Solution { BufferedReader br; StringTokenizer st; { st = null; br = new BufferedReader(new InputStreamReader(System.in)); } public static void main(String[] args) throws Exc...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
d6b5ab156a4476d20cc25287740e54ae
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
/* ID: tommatt1 LANG: JAVA TASK: */ import java.util.*; import java.io.*; public class cf1141g{ static ArrayList<pair>[] adj; static int min; static int[] col; public static void main(String[] args)throws IOException { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = ne...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
f272ea42992ee8368cee541ab9d55d0b
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; public class Task { public static void solve() throws Exception { int n = nextInt(); int k = nextInt...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
f74931043f2c0d136ec50bb8da485ec4
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
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.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
cb7f39bec44de6c34aa7f0a0173f87bd
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedInputStream; import java.util.HashMap; import java.util.HashSet; import java.io.FilterInputStream; import java.util.Comparator; import java.io.InputStream; /*...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
389e8f1d2567acafb1ab87bad3cee04d
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; public class MainClass { static int n = 0; static int k = 0; static ArrayList<Integer>[] adj; static ArrayList<Integer>[] indices; static boolean[] visited; static int ans = -1; static int[] mark; static StringBuilder stringBuilder = new StringBuild...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
5b38f4c03baab3cfaa8cb01ba6ab0008
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.regex.*; import java.util.stream.LongStream; public class Main{ static ArrayList a[]=new ArrayList[5000001]; static TreeSet<Integer>tr=new TreeSet<>(); static ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
15f3831d376d45d51171fd9c43f109e4
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; public class Main { /*********************************************Constants******************************************/ static PrintWriter out=new PrintWriter(new OutputStreamWr...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
2b01270bf80210377d27f779c4dee5cc
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN //Code not meant for understanding, proceed with caution void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(), k = ni(); int[][] e...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
9a37ea24191fd7fb856bf24e9f8c78e6
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; /* spar5h */ public class cf2 implements Runnable { static class Edge { int u, v; Edge(int u, int v) { this.u = u; this.v = v; } int other(int x) { if(x == u) return v; return u; } } static class Pa...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
a9882d62de69e903f83c9a3a2e02713b
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import jav...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
a63b09bb4e42d6446fcc1ad7b85a13c1
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { new Main().go(); } PrintWriter out; Reader in; BufferedReader br; Main() throws IOException { try { //br = new BufferedReader( new FileReader("in...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
a80d3038f4aa269b68db6f58ecf7c03f
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static class node implements Comparable<node> { int u,id; node(){} node(int u,int id) { this.u=u; this.id=id; } @Override public int compareTo(node rhs) { return rhs.u-u; } } static ArrayList<node>[] G=new ArrayList[212345]; sta...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
26cc9021e7717d6cf6f6b5ab27013d79
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Scanner; public class G { private static int n, k; private static Tree tree; private static int r; private static int[] c; public static void main(String[] a...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
cbf2b0290fdef943654337d19f16045a
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.LinkedList; import java.util.Scanner; public class G { private static int n, k; private static Tree tree; private static int r; ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
cf3c993fc03fe4c85bec2421f3955562
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
e45288e1ab300e9b8c4e402842bf77fa
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
ddc373565b8daf0e39c27cab58e2bcfc
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class G { String filename = null; final int INF = 1_000_000_000; int last; List<Edge>[] g; int[] vertexes, colors, startColors; boolean[] used; void dfs(int v){ used[v] = ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
2e113c61b084b14b408c364fd3591d56
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.BitSet; import java.util.Collections; import java.util.LinkedList; public class CF1141G { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamRead...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
ec4758d63e9cb0325d318c10848331da
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; public class ProblemG { public static InputStream inputStream = System.in; public static OutputStream outputStream = System.out; public static void main(String[] args) { MyScanner scanner = new MyScanner(inputStream); PrintWriter out = new PrintWrite...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
24947d14ad072d4075a76c2528f5a5b9
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.Point; public class CF_1141G { static ArrayList<ArrayList<Integer>> adj; public static void main(String args[]) throws Exception { BufferedScanner in = new BufferedScanner(System.in); BufferedPrinter out = new BufferedPrinter(System.out); ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
0fae8b848ba43c1739aa5b59db45462c
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.Point; public class CF_1141G { static ArrayList<ArrayList<Integer>> adj; public static void main(String args[]) throws Exception { BufferedScanner in = new BufferedScanner(System.in); BufferedPrinter out = new BufferedPrinter(System.out); ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
17ab9aab45967b272354ef94f31621f7
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.List; public class Q7 { public static void main(String[] args) { InputReader s = new ...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
d4a9a93a9d3b473716c9c7d07bf778e6
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main{ class Node { int id; int x; public Node(int id,int x){ this.id=id; this.x=x; } } void solve() { n=ni(); k=ni(); g=new ArrayList[n+1]; for(int i=1;i<=n;i++) g[i]=...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
8cf8399f549287e359e4d828c48eeb93
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.util.*; import java.io.*; public class Mainfre { public static class node implements Comparable<node> { int u,id; node(){} node(int u,int id) { this.u=u; this.id=id; } @Override public int compareTo(node rhs) { return rh...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
6566ece25aca38472106e973c720f88c
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class TaskG { private static Map<Integer, List<Integer>> adjacent = new HashMap<>(); private static Map<Integer, List<Integer>> roadIndex = new HashMap<>(); private static int colorCount;...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
94333b093243dca4208b1970b7c69643
train_001.jsonl
1553006100
Treeland consists of $$$n$$$ cities and $$$n-1$$$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right β€” the country's topology is an undirected tree.There are some private road companies in Treeland. The government decided to sell ...
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.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["6 2\n1 4\n4 3\n3 5\n3 6\n5 2", "4 2\n3 1\n1 4\n1 2", "10 2\n10 3\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9"]
2 seconds
["2\n1 2 1 1 2", "1\n1 1 1", "3\n1 1 2 3 2 3 1 3 1"]
null
Java 8
standard input
[ "greedy", "graphs", "constructive algorithms", "binary search", "dfs and similar", "trees" ]
0cc73612bcfcd3be142064e2da9e92e3
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200000, 0 \le k \le n - 1$$$) β€” the number of cities and the maximal number of cities which can have two or more roads belonging to one company. The following $$$n-1$$$ lines contain roads, one road per line. Each line contains a pair of integers ...
1,900
In the first line print the required $$$r$$$ ($$$1 \le r \le n - 1$$$). In the second line print $$$n-1$$$ numbers $$$c_1, c_2, \dots, c_{n-1}$$$ ($$$1 \le c_i \le r$$$), where $$$c_i$$$ is the company to own the $$$i$$$-th road. If there are multiple answers, print any of them.
standard output
PASSED
cdaec304d7da4e6a5a2bfe2481ac2f8e
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.*; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader("input.txt")); o...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 8
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
b9599174c5f7b432674889dcf0b6c5ff
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { final static boolean debug = false; final static String fileName = ""; final static boolean useFiles = false; public static void main(String[] args) throws FileNotFoundException { PrintWriter writer = new PrintWrite...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 8
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
c72c312f454e9704e6348d123ad54197
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.*; import java.io.*; public class TaskC { class Summarizer { int n; long[] keys; long[] sum; void updateSum(int pos, long value) { while (pos <= n) { sum[pos] += value; pos = (pos | (pos - 1)) + 1; } }...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
df401f3481f0a82bf24ff97092276164
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { private BufferedReader in; private PrintWriter out; private StringTokenizer st; private void eat(String line) { st = new StringTokenizer(line); } private String next() throws IOException { while (!st.hasMoreTokens()) { Stri...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
c6d333c7759ee91327efd3689a8b33ec
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class C { int[][] children; int[] keys; Integer[] sorted; int[] toSorted; double[] expected; private int n; public void run() { n = nextInt(); children = ...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
eb6d8ce8b9cb6d0102f3096bed7fcbbf
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.*; import java.util.*; public class Solution implements Runnable { BufferedReader input; StringTokenizer tokenizer; PrintWriter output; int n; int[] p; int[] val; int[] left; int[] right; int[] depth; int[] minleft; int[] maxright; int[] minlefti; int[] maxrighti; long[] sum; int root;...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
e995f8dc2b1f4f4b6dc63fa5b3683972
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.*; import static java.lang.Math.*; import java.io.*; public class C implements Runnable{ static int N, K; static Node[] T; static int root, numleaves; static int[] max; static double[] avg; static int[] Q; public static void main(String[] args) throws Exception{ BufferedReader in = new Buffer...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
a48147a9c174111420c702edd03141fe
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.InputMismatchException; import java.util.Comparator; import java.io.*; import java.util.Locale; import java.util.SortedSet; import java.util.Arrays; /** * Generated by Contest helper plug-in * Actual solution is at the bottom */ public class Main { public static void main(String[] args) { ...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
32d4fd1a30b7f24d6413ad65954d6720
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.InputMismatchException; import java.util.Comparator; import java.io.*; import java.util.Locale; import java.util.SortedSet; import java.util.Arrays; /** * Generated by Contest helper plug-in * Actual solution is at the bottom */ public class Main { public static void main(String[] args) { ...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
1cc9c533450b776349ab301dc9a0802d
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.*; import java.io.*; public class C_as { FastScanner in; PrintWriter out; int[] l; int[] r; long[] v; long[] sumv; int[] vl; long[] max; long[] min; int root; int[] lcp; int[] li; long[] lv; int ln; int[] depth; void dfs(int u) { ...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
f587196c4ac6e5a7b9c88107f3908ac3
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.util.*; public class C { private static Scanner in; int n; int[] key; int[] parent; int[] left; int[] right; int[] from; int[] to; int[] size; int root; public void run() { n = in.nextInt(); key = new int[n]; parent = new int[n]; left = new int[n]; right = new int[n]; from = new i...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
64ae2d929c46b5e56b83ea230d119556
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Locale; import java.util.StringTokenizer; public class C implements Runnable { int[] left; int[] ri...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
c59fdbf59e95806a4b195fdfb00ffbf9
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.lang.*; import java.math.BigInteger; import java.io.*; import java.util.*; public class Solution implements Runnable{ public static BufferedReader br; public static PrintWriter out; public static StringTokenizer stk; public static boolean isStream = true; public static void main(String...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
f0cb3006d6b0817502d8e337e6a71661
train_001.jsonl
1305903600
One night, having had a hard day at work, Petya saw a nightmare. There was a binary search tree in the dream. But it was not the actual tree that scared Petya. The horrifying thing was that Petya couldn't search for elements in this tree. Petya tried many times to choose key and look for it in the tree, and each time h...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Comparator; import java.util.HashMap; import jav...
Java
["7\n-1 8\n1 4\n1 12\n2 2\n2 6\n3 10\n3 14\n1\n1", "3\n-1 5\n1 3\n1 7\n6\n1\n2\n4\n6\n8\n9"]
3 seconds
["8.0000000000", "7.0000000000\n7.0000000000\n7.0000000000\n3.0000000000\n3.0000000000\n3.0000000000"]
NoteIn the first sample the search of key 1 with one error results in two paths in the trees: (1, 2, 5) and (1, 3, 6), in parentheses are listed numbers of nodes from the root to a leaf. The keys in the leaves of those paths are equal to 6 and 10 correspondingly, that's why the answer is equal to 8.
Java 6
standard input
[ "probabilities", "sortings", "binary search", "dfs and similar", "trees" ]
afe77e7b2dd6d7940520d9844ab30cfd
The first line contains an odd integer n (3 ≀ n &lt; 105), which represents the number of tree nodes. Next n lines contain node descriptions. The (i + 1)-th line contains two space-separated integers. The first number is the number of parent of the i-st node and the second number is the key lying in the i-th node. The ...
2,200
Print k real numbers which are the expectations of answers for the keys specified in the input. The answer should differ from the correct one with the measure of absolute or relative error not exceeding 10 - 9.
standard output
PASSED
82bee039a3337c6178673e9d98691aab
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static long sx = 0, sy = 0, mod = (long) (1e9 + 7); static ArrayList<Integer>[] a; static int[][] dp; static int[] size; static long[] farr; public static PrintWriter out; static ArrayList<pair> p = new ArrayList<>(); sta...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output
PASSED
440d0cb6076c1dc9b35188817aa3edbb
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
/** * @author egaeus * @mail sebegaeusprogram@gmail.com * @veredict Not sended * @url <https://codeforces.com/problemset/problem/608/B> * @category two pointers * @date 6/06/2020 **/ import java.io.*; import java.util.*; import static java.lang.Integer.*; import static java.lang.Math.*; public class CF608B {...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output
PASSED
376919e09a2a5a6eabe231282e513e45
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
import java.util.Scanner; public final class HamingDistanceSum { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=sc.next(); String b=sc.next(); int n=a.length(); int m=b.length(); int prefix[][]=new int[2][m]; if(b.charAt(0...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output
PASSED
b8db8d05b3907ed396c1c67eb9cf49e7
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main (String[] args) { new A(); } public A() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println(""); char[] a = fs.next().toCharArray(); char[] b = fs.next().toCharArray(); int...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output
PASSED
4b914e8c0ae391ca7debcb31898f0ca9
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
// https://codeforces.com/contest/182/submission/70317507 import java.math.*; import java.util.*; import java.io.*; public class B { static BufferedReader in; static String file = "../in"; static int test = 10; // 0 for local testing, 1 for std input static String[] split() throws Exception ...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output
PASSED
4127ef921837722a04fec8c3c8ac706d
train_001.jsonl
1450888500
Genos needs your help. He was asked to solve the following programming problem by Saitama:The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeSet; import javax.swing.event.Tree...
Java
["01\n00111", "0011\n0110"]
2 seconds
["3", "2"]
NoteFor the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts ...
Java 11
standard input
[ "combinatorics", "strings" ]
ed75bd272f6d3050426548435423ca92
The first line of the input contains binary string a (1 ≀ |a| ≀ 200 000). The second line of the input contains binary string b (|a| ≀ |b| ≀ 200 000). Both strings are guaranteed to consist of characters '0' and '1' only.
1,500
Print a single integerΒ β€” the sum of Hamming distances between a and all contiguous substrings of b of length |a|.
standard output