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
b856d04b53a0d992dced76a2b13c78d1
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import static java.lang.Math.*; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.StringTokenizer; import java.io.PrintStream; i...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n < 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
3847d6a16cbdd2510fe4fe8d86e0620c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class StrangeFunctions { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); do { String s = new String(); if(sc.hasNext()){ s= sc.next(); } Syst...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n < 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
898d34998c97b7c684412ad1add25e74
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class UVA10550 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int T = s.nextInt(); for(int tt= 0;tt<T;tt++) { String in = s.next(); int c = in.length(); //int pos = c-1; //while(in.charAt(pos--)=='0'){ // c--; // } System.out.printl...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
5d8a7aefd12426473522a667afc94c7c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class A { static int INF = 1000000007; public static void main(String[] args) { int test = fs.nextInt(); // int test = 1; for (int cases = 0; cases < test; cases++) { String s = fs.next(); int a = s.length(); if (a == 1) { System.o...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
9b757ccf00ba731496f03f40e1e7161e
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { FastScanner f = new FastScanner(); int t=f.nextInt(); // int t=1; while(t-->0){ // int n=f.nextInt(); // int ans=1000000; String a=f.next(); System.out.pr...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
efccf0b2b993ed2503873d8d45277143
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class firstProg { public static void main(String[] args) throws IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(sc....
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
b955b33b0fdbe4c8d4fbaa2c9aaac308
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; public class codeforces { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0) { int result=0; String s=br.r...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
63b5f1403bcb46888aca3609c4cec49c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.lang.*; import java.util.*; public class Codeforces { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); s.nextLine(); for(int i=0;i<t;i++) { String str=s.nextLine(); ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
161d5d0d89a15a970291d177bf9a943c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.InputStreamReader; import java.util.ArrayList; import java.io.BufferedReader; import java.io.IOException; public class infOly6 { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int x = Integer.parseInt(r.readLi...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
f57eb20373c99ab9cde928f56045faad
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import com.sun.source.tree.Tree; import java.io.*; import java.util.*; // ▄▀▀▀▀▄ ▄▀▀▄ ▄▄ ▄▀▀▀▀▄ ▄▀▀▄ █ ▄▀▀█▄▄▄▄ ▄▀▀▄▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄ // █ █ ▐ █ █ ▄▀ █ █ █ █ ▄▀ ▐ ▄▀ ▐ █ █ █ █ █ ▐ █ █ ▐ █ █ ▐ // ▀▄ ▐ █▄▄▄█ █ █ ▐ █▀▄ █▄▄▄▄▄ ▐ █▀▀█▀ ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
986864bea173ab776824e92f155093c7
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import com.sun.source.tree.Tree; import java.io.*; import java.util.*; // ▄▀▀▀▀▄ ▄▀▀▄ ▄▄ ▄▀▀▀▀▄ ▄▀▀▄ █ ▄▀▀█▄▄▄▄ ▄▀▀▄▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄ // █ █ ▐ █ █ ▄▀ █ █ █ █ ▄▀ ▐ ▄▀ ▐ █ █ █ █ █ ▐ █ █ ▐ █ █ ▐ // ▀▄ ▐ █▄▄▄█ █ █ ▐ █▀▄ █▄▄▄▄▄ ▐ █▀▀█▀ ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
db78e0b2457317e8c814ee1cf1ebacbb
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class l { public static void main(String args[]){ Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int i=0;i<t;i++){ String str=s.next(); System.out.println(str.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
7f1f01bb622cbb95d3880d81c5d579de
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1455a { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { prln(rcha().length); } close(); } static ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
c3143afe9f192d483acb8e7e87f193cf
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class Raund { public static void main(String[] args) { int t = Reader.readInt(); while (t --> 0) { String line = Reader.readLine(); Writer.add(line.length()); Writer.lineBreak(); } W...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
1b0b0aa2e1a5eedc8228647171e626ac
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class CodeChef2 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } S...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
4d86f9b9e8aa11d596184508735a9402
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class ytt { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt();int c=0; for(int i=1;i<=t;i++) { String s=sc.next(); c=s.length(); System.out.println(c); } }}
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
ba1048b12814369cdc0f4c9e04b930f6
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); Integer testCases= input.nextInt(); while(testCases!=0) { BigInteger number = input.nextBigInteger(); int digits =...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
7a8d7ded6b38ae4f67b3c5f6aee60465
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.StringTokenizer; public class A { public static class FastIO { public static final int DEFAULT_BUFFER_SIZE = 65536; public static final int DEFAULT_INTEGER_SIZE = 11; publi...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
f368d4388d77f1028dbd43cc4f8cda21
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; import java.io.*; public class A{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
d4eb21c483c439df6f97758d3a66d8e7
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); int count = 0; while(t > 0) { BigInteger n = input.next...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
98b4e832026a7103555c658b070f8e63
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.Scanner; public class StrangeFunctions { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataI...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
b2dcf5a49ccb00292e0151d6a415cee8
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test = scanner.nextInt(); for (int i = 0; i < test; i++) { BigInteger n = scanner.nextBigInteger(); System.o...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
c352c3958d6f3855c4f1c8b3bad15783
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Test1 { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++) { BigInteger a = sc.nextBigInteger(); BigInteger c = B...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
5b454abd8b15990c87d6ec2bb6e46f14
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; import java.math.*; public class Main{ public static void main(String args[]) { Scanner sc= new Scanner(System.in); int t= sc.nextInt(); sc.nextLine(); while(t-- !=0) { BigInteger n = new BigInteger(sc.next...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
3584dbcd8397ad2e08443d6d3b448a84
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static int total(BigInteger a){ BigInteger temp = a; int b = 0; int r = 10; do{ temp = temp.divide(BigInteger.valueOf(r)); b ++; }while (temp != BigInteger.ZERO); ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
efc43b570f065343a03dd9bc3221d7f9
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.util.Scanner; public class StrangeFunctions { public static int getCount(BigInteger number) { double factor = Math.log(2) / Math.log(10); int Count = (int) (factor * number.bitLength() + 1); if (BigInteger.TEN.pow(Count - 1).compareTo(number) ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
3f25b2e5c613d7e5f682d370a2c57f1a
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Edu9982 { public static int getDigitCount(BigInteger number) { double factor = Math.log(2) / Math.log(10); int digitCount = (int) (factor * number.bitLength() + 1); if (BigInteger.TEN.pow(digitCount - 1).compareTo(number) > 0) { r...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
a2bf5faad0107dcd68eb44abf3d3f9c8
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class StrangeFunc { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t = Integer.parseInt(sc.nextLine()); String n; for(int i=t;i>0;i--) { n=sc.nextLine(); int ans=n.length(); System....
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
efadc8c2e53854bb636131488b289f4f
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayDeque; import java.util.InputMismatchExcepti...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
5b4b7330105726522034699892de1b08
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; import java.io.*; public class BalancedRemovals { public static void main(String[] args) { FS scan = new FS(); int n = scan.nextInt(); Pt[] arr = new Pt[n]; int[] next = new int[n]; Arrays.fill(next, -1); for(int i = 0; i < n; i++){ arr[i] = new Pt(scan.nextInt(), scan.nextInt()...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
a796d89debd1007a00a334e1b91111a1
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; import java.util.stream.IntStream; import java.io.*; public class BalancedRemovalshard { /************************ SOLUTION STARTS HERE ************************/ static int pairing[][]; static int pts[][]; static int ptr; static Integer order[]; stat...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
904760761bbaf88c6369f9d23159748c
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; public class ProblemF { public static void main (String[] strings){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); TreeMap<Integer, List<Triple>> map = new TreeMap<>(); for (int i = 1; i <= n; i++) { int x = scanner.nextInt(); ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
ee3fc2a109df847b95b006912365e5ab
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import javax.print.attribute.IntegerSyntax; import java.io.*; import java.util.*; /** * A simple template for competitive programming problems. */ public class Banana { final InputReader in = new InputReader(System.in); final PrintWriter out = new PrintWriter(System.out); final long mod = 1000000009; ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
f0d31aadb3d5ee9aef260ca7ba7a9a85
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Collections;...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
ddee5f1d58a80712542d5efb87fc910d
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
076aa00bcb57b9aed6a4124bd9aa2b81
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class c { static StringBuilder sol; public static void main(String[] args) { FS scan = new FS(System...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
bd6a340d3e712819bdba386a8b8be475
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.Comparator; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
d684e2d208d8015e384b1f1474036f6f
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; import java.io.*; public class c { static int oo = 1_000_000_000; public static void main(String[] args) { FS in = new FS(System.in); PrintWriter out = new PrintWriter(System.out); TreeSet<Integer> xComp = new TreeSet<Integer>(); TreeSet<Integer> yComp = new TreeSet<Integer>()...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
7cca45e301ef0ed7f7fd36b2bb2461ae
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.AbstractMap; import java.util.TreeMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
39a9353626e65b4b36478e20010c65c3
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; public class TestGenerator { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter wr = new PrintWriter(System.out); int n = sc.nextInt(); int[][] p = new int[n][4]; for (int i = ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
d8af17ded0e53ecd38e8120df84f4e88
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class q5 { public static void main(String[] args) throws IOException { Reader.init(System.in); PrintWriter out=new PrintWriter(System.out); int n=Reader.nextInt(); TreeMap<Integer,NoD> xmap=ne...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
7fdcf3ec5709399b8c77bbbc07bf53e2
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; public class C implements Runnable { public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println(""); int n = fs.n...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
27d3fbecda44cca66e159213d078d518
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; public class Main { static final long MOD = 998244353; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); int N = sc.nextInt(); int[][] points = new int[N][4]; for (int i = 0; i < N; i++) { ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
1551d7142add95297f2f440e3abbcdeb
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 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.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; i...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
73c5c29919f5d0efc59d2d5f5df98ee1
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; im...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
5547fadcff0fdc6d83fc71be23f92c67
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.Collection; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayLi...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
8d67014904150837e3a991e5e0670d39
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int MOD = 1000000007; // After writing solution, quick scan for: // array out of bounds // special cases e.g. n=1? // // Big numbers arithmetic bugs: // int overflow // sorting, or tak...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
dc9c2a4273897194ef529c748d1442a4
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.util.Random; import java.util.Comparator; import java.util.ArrayList; import java.io.InputStream; /...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
64771866e2d47b5ab7dbbd7ad82dd973
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 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.hasMoreTok...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
242212765208e38629c0bd4e2bae59fe
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { class Reader { BufferedReader in; Reader() { in = new BufferedReader(new InputStreamReader(System.in)); } StringTokenizer tok = new StringTokenizer(""); String next() th...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
ba0ec8cce13dd6a12c6f10f222465e98
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { class Reader { StreamTokenizer tok; Reader() { tok = new StreamTokenizer(new BufferedInputStream(System.in)); } String next() throws IOException { tok.nextToken(); ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
2472e6f149725e80022031253af1631d
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Remo { ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
c379cf8b2c7187a6f2b9320349e08a01
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Remo { ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
ba640040dc2c54e498eacd8472b468d4
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Remo3D {...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
d956f68c1e862f93f46ac1b53ab92cfa
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Remo3D {...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
4cf0b61641aa7518ec0107e8e3df1068
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; public class C { static class Point implements Comparable<Point> { int x, y, z, index; public Point(int index, String coordinate) { this.index = index; String[] ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
3c290b371456fa9310d3f804f3ca72dc
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.*; import java.math.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; //class Declaration static class pair implement...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
74a9a896e9e95fe4658f85791db40a7f
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); dataC str[]=new dataC[n+1]; str[0]=new dataC(); for(int i=1;i<=n;i++) { str[i]=new dataC(); str[i].x=sc....
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
ed84f7000e12dfaf6f51bc4b0b2a5d63
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gcd(long a,long b) { return b==0?a:gcd(b,a%b);...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
84bf105562aea95b17fc1683d2233e9d
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static Point[] arr; static Point solveZ(ArrayList<Point> a) { Collections.sort(a, (o1, o2) -> Integer.compare(o1.z, o2.z)); for (int i = 0; i < a.size() -...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
454e2b4951d01ba255e768b275104f40
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.*; import java.nio.CharBuffer; import java.util.*; public class P1237C2 { public static void main(String[] args) { SimpleScanner scanner = new SimpleScanner(System.in); PrintWriter writer = new PrintWriter(System.out); int n = scanner.nextInt(); TreeMap<Integer, Tre...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
200fa4c7044b708cb64e8211f3724d60
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main (String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int arr[][] = new int[n][4]; for(int i=0;i<n;i++) ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
f100fb1549e5b5fb1803abe4b8210e3e
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; public class C { static final PrintWriter out = new PrintWriter(System.out); ...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
027f6e18cdbb50f50aee49ced59b5250
train_000.jsonl
1571236500
This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a se...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.io.InputStream...
Java
["6\n3 1 0\n0 3 0\n2 2 0\n1 0 0\n1 3 0\n0 1 0", "8\n0 1 1\n1 0 1\n1 1 0\n1 1 1\n2 2 2\n3 2 2\n2 3 2\n2 2 3"]
1 second
["3 6\n5 1\n2 4", "4 5\n1 6\n2 7\n3 8"]
NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after ...
Java 8
standard input
[ "greedy", "constructive algorithms", "implementation", "divide and conquer", "sortings", "binary search" ]
3d92a54be5c544b313f1e87f7b9cc5c8
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points c...
1,900
Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many so...
standard output
PASSED
67ea9c2bc2971dfbd660aad44a051d51
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); int a = 0; int x = 0; int b = input.nextInt(); int d = input.nextInt(); int sum= 0; for (int i = 0; i < n;...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
048c2c26ae9ce36fce0d9d2e8c518a55
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.Scanner; public class Juicer { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int b = in.nextInt(); int d = in.nextInt(); in.nextLine(); int w = 0, o=0, f=0; for (int i = 0; i < n; i++) { o=in.nextInt(); if(b>=o) { w+=o; ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
cde59c08889fbd5135e64f994d027b05
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.lang.*; import java.util.Scanner; import java.util.*; import java.io.*; public class TestClass { public static void main(String args[] ) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] arr = new int[n]; ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
2b8181b1f1fa646a77734526d343f52b
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.util.StringTokenizer; public class Main { public static void main(String[] args)throws IOExcepti...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
a55e2251317feabac58eea0fcab9d7ac
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.Scanner; public class solution{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int size=scan.nextInt(); int waster=scan.nextInt(); int sum=0; int counter=0; for(int i=0;i<n;i++) { ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
f74b281929133fc625ff25720ff19770
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.Scanner; public class solution{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int size=scan.nextInt(); int waster=scan.nextInt(); int sum=0; int counter=0; for(int i=0;i<n;i++) { ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
43837255696569af0b3cf1c60daa179e
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
//package acm; /* * 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. */ import java.util.HashMap; import java.util.Scanner; /** * * @author adMath.min */ import java.math.*; public class...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
82be6cdbd985e634afc74ba434dc411c
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class juicer { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter writer = new BufferedWriter(new OutputStream...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
fe41249e61d2c513daad16789b736c99
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class juicer { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] info = reader.readLine().split(" "); int o...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
2c5e8090ad43e3bcb2974be502b5f1f4
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int b = sc.nextInt(); int d = sc.nextInt(); int[] arr = new int[n]; for(int i=0;i<n;i++) arr[i] = sc.nextInt(); long sum = 0; int c = 0; for(int i=0;i<n;i++){...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
65c57ba925e10d68effa1ef39e9d94c5
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.Scanner; public class CF709_D2_A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int b = sc.nextInt(); int d = sc.nextInt(); long sum = 0; int c = 0; for (int i=0;i<n;i++){ i...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
e95acaa1d5d66a0658684bbb1ea27885
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class abc { public static void main(String ar[])throws IOException { Scanner sc=new Scanner(System.in); int n,b,c=0,e=0,d; n=sc.nextInt(); b=sc.nextInt(); d=sc.nextInt(); int A[]=new int[n]; ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
0e474abf38445cec851e4c1e303282b1
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class abc { public static void main(String ar[])throws IOException { Scanner sc=new Scanner(System.in); int n,b,c=0,e=0,d; n=sc.nextInt(); b=sc.nextInt(); d=sc.nextInt(); int A[]=new int[n]; ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
60c451cd0b52bd39659036f89b4288f6
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.io.*; import java.util.Locale; import java.util.StringTokenizer; public class SolutionTest implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) { new Thread(null, new SolutionTest(), "", 256...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
e39df57d17f565996729d5f8ca55932b
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.nio.Buffer; import java.util.*; public class Pair { static class FastReader { private BufferedReader br; private StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
ba3674df3b8e65878a5aaf48798e8c29
train_000.jsonl
1472056500
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr...
256 megabytes
import java.util.Scanner; public class Comp { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int b = input.nextInt(); int d = input.nextInt(); int t = 0; int s; int f = 0; ...
Java
["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"]
1 second
["1", "0", "1", "0"]
NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
Java 8
standard input
[ "implementation" ]
06e9649963715e56d97297c6104fbc00
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, .....
900
Print one integer — the number of times Kolya will have to empty the waste section.
standard output
PASSED
ce97b43c7c4a570a3026be64bc7f3856
train_000.jsonl
1332860400
In some country live wizards. They like to make weird bets.Two wizards draw an acyclic directed graph with n vertices and m edges (the graph's vertices are numbered from 1 to n). A source is a vertex with no incoming edges, and a sink is the vertex with no outgoing edges. Note that a vertex could be the sink and the so...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class E { private static int MOD; public static void main(String [] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStr...
Java
["4 2 1000003\n1 3\n2 4", "4 2 1000003\n4 1\n3 2", "4 4 1000003\n2 1\n2 4\n3 1\n3 4", "6 5 1000003\n1 4\n1 5\n1 6\n2 6\n3 6", "5 2 1000003\n5 1\n3 4"]
3 seconds
["1", "1000002", "0", "0", "1"]
NoteIn the first sample, there is exactly one set of paths — . The number of inversions is 0, which is an even number. Therefore, the first wizard gets 1 coin.In the second sample there is exactly one set of paths — . There is exactly one inversion. Therefore, the first wizard gets -1 coin. .In the third sample, there ...
Java 8
standard input
[ "graphs", "dfs and similar", "math", "matrices" ]
3247c416952cd4335ec9319cd0ef0da2
The first line contains three space-separated integers n, m, p (1 ≤ n ≤ 600, 0 ≤ m ≤ 105, 2 ≤ p ≤ 109 + 7). It is guaranteed that p is prime number. Next m lines contain edges of the graph. Each line contains a pair of space-separated integers, ai bi — an edge from vertex ai to vertex bi. It is guaranteed that the grap...
2,900
Print the answer to the problem — the total winnings of the first player modulo a prime number p. Please note that the winnings may be negative, but the modulo residue must be non-negative (see the sample).
standard output
PASSED
5cce311b9ca94408bbd6f809bbb909be
train_000.jsonl
1332860400
In some country live wizards. They like to make weird bets.Two wizards draw an acyclic directed graph with n vertices and m edges (the graph's vertices are numbered from 1 to n). A source is a vertex with no incoming edges, and a sink is the vertex with no outgoing edges. Note that a vertex could be the sink and the so...
256 megabytes
import java.io.OutputStream; import java.io.PrintWriter; import java.util.Random; import java.util.Collection; import java.util.List; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.util.NoSuchElementException; import java.util.TreeSet; import java.io.InputStream; /** * Bu...
Java
["4 2 1000003\n1 3\n2 4", "4 2 1000003\n4 1\n3 2", "4 4 1000003\n2 1\n2 4\n3 1\n3 4", "6 5 1000003\n1 4\n1 5\n1 6\n2 6\n3 6", "5 2 1000003\n5 1\n3 4"]
3 seconds
["1", "1000002", "0", "0", "1"]
NoteIn the first sample, there is exactly one set of paths — . The number of inversions is 0, which is an even number. Therefore, the first wizard gets 1 coin.In the second sample there is exactly one set of paths — . There is exactly one inversion. Therefore, the first wizard gets -1 coin. .In the third sample, there ...
Java 6
standard input
[ "graphs", "dfs and similar", "math", "matrices" ]
3247c416952cd4335ec9319cd0ef0da2
The first line contains three space-separated integers n, m, p (1 ≤ n ≤ 600, 0 ≤ m ≤ 105, 2 ≤ p ≤ 109 + 7). It is guaranteed that p is prime number. Next m lines contain edges of the graph. Each line contains a pair of space-separated integers, ai bi — an edge from vertex ai to vertex bi. It is guaranteed that the grap...
2,900
Print the answer to the problem — the total winnings of the first player modulo a prime number p. Please note that the winnings may be negative, but the modulo residue must be non-negative (see the sample).
standard output
PASSED
f22936c4632bc4afcf0bb9e9b0ce95f4
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
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
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
dc416a401d04549d1abbf81e3f58e08b
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.*; import java.util.*; public class MyClass { public static void main(String args[]) { FastReader sc = new FastReader(); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<Integer> adj[] = new ArrayList[m+1]; for (int i = 1; i <=m; i++) { adj[i] = ne...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
cea35ba86291d78636ab6916f393a98f
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; /** * Created by akshaysharma on 28/11/16. */ public class Problem277A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = s...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
76327aeea8181db35d1c3b885cf41011
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { //1: Declare/Define vari...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
3203c11ea5c0ee3011e549b6e58d54d0
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class Main { static InputStreamReader reader = new InputStreamReader(System.in); static BufferedReader in = new BufferedReader(...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
c61ebd0268d8cb4b73c1933337caaca5
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; public class Test{ static int graph[][]; static boolean visited []; static int n,m; public static void dfs(int i){ visited[i] = true; for(int j=0;j<m;j++){ if(graph[i][j] == 1) for(int k=0;k<n;k++){ ...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
2c6c1e757158e5fbbe07598f24b961dc
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Set; import java.util.Stack; public class Solution { public static void main(String[] args) throws Exception { // TODO ...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
954a70530eafe01b951de3e1fce70c81
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Set; import java.util.Stack; public class Solution { public static void main(String[] args) throws Exception { // TODO ...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
fa8683ae298808c62e90a78da4c977fb
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class A277{ static int gcd(int a, int b) { if (a == 0) return b; if (b == 0) return a; int k; for (k = 0; ((a | b) & 1) == 0; ++k) { a >>= 1; ...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
bbed65e681f8df713b507271fa4720e7
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
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.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.uti...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
8c7117986ad9d02f39edafc2d726cee6
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
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.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.uti...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
8f83c2b75756d3962b3491c4d25888be
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; public class LearningLanguagesA { static HashSet<Integer> p; static ArrayList<Integer> ap; static ArrayList<Integer> arr[]=new ArrayList[201]; static boolean vis[]=new boolean[201]; public stati...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
f2ae0ef8389c9230367736cd88878650
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; import java.util.concurrent.LinkedBlockingDeque; import java.io.*; import java.lang.*; public class graph1 { public static int n; public static ArrayList<Integer> adj[]; public static ArrayList<Integer> adj2[]; public static ArrayList<Integer> child[]; public static boolean[] vis; ...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
70c5d1097dad40427faf40dc86beb0f7
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main (String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] temp=br.readLine().trim().split(" "); int V=Integer.parseInt(temp[0]); int totalLanguages=Integer.parse...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
28c585b2d15d2108675239622b572243
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main (String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] temp=br.readLine().trim().split(" "); int V=Integer.parseInt(temp[0]); int E=Integer.parseInt(temp[1]);...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
12f14dee9f35ec686b0d04f6cea6e38a
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.*; import java.util.*; public class A277 { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s[]=br.readLine().trim().split(" "); int n=Integer.parseInt(s[0]); int m=Integer.p...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
4f9b4f82e62778e81909ad991c5205a2
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main{ /* . . . . . . . some constants . */ static boolean visited[]; static ArrayList<Integer> list[]; static void dfs(int current){ visited[current]=true; Iterator itr=list[current].listIterator(); int temp;...
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output
PASSED
a1a717080121e00ffd5c53e4a2e58994
train_000.jsonl
1362065400
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official language...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * @author pvasilyev * @since 30 Mar 2017 */ public class A277 { public static void main(String[] args) throws IOException { final Scanner reader = new Scanner(new InputStreamReader(System....
Java
["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0"]
2 seconds
["0", "2", "1"]
NoteIn the second sample the employee 1 can learn language 2, and employee 8 can learn language 4.In the third sample employee 2 must learn language 2.
Java 8
standard input
[ "dsu", "dfs and similar" ]
e2836276aee2459979b232e5b29e6d57
The first line contains two integers n and m (2 ≤ n, m ≤ 100) — the number of employees and the number of languages. Then n lines follow — each employee's language list. At the beginning of the i-th line is integer ki (0 ≤ ki ≤ m) — the number of languages the i-th employee knows. Next, the i-th line contains ki intege...
1,400
Print a single integer — the minimum amount of money to pay so that in the end every employee could write a letter to every other one (other employees can help out translating).
standard output