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
5b88c777cd01b3e919ce009ced252aa7
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; public class trains{ static ArrayList<edge>[] ady; static ArrayList<edge>[] ady2; static int n; static int l; static long[] d...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
5f5091a8e39856481908f4be4cb0da86
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.TreeSet; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author George ...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
23c86f90b14baf11b33ff8a1752e171e
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
import static java.lang.Math.*; import java.io.*; import java.util.*; public class A { BufferedReader in; PrintWriter out; StringTokenizer st; public String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(in.readLine()); } catch(Exception e) {} } return st...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
415194dd3f57427f31199896e6af2255
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
/* ID: govind.3, GhpS, govindpatel LANG: JAVA TASK: Main */ import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { /** * Min segment Tree takes the minimum number at the root */ class MinSegmentTree { /** * root: Tree root, balance: input array...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
cd5bf8cbd74f8a2dd4326d8fe004f493
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.PriorityQueue; public class B { private static final long INF = 1000000000000000...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
2180304e09cd4ba5e45bfaa5feccf2d0
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main{ FastScanner in; PrintWriter out; public class Edge { int to; long w; public Edge(int to, long w) { this.to = to; this.w = w; } } public class myStruct implements C...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
02b3ec41311288e21d1a0c6a44058e0a
train_001.jsonl
1405774800
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
256 megabytes
//package CF; import java.util.*; import java.io.*; public class CFD_257 { static long[] dis = new long[500010] ; static boolean[] parent = new boolean[500010] ; static boolean[] vis = new boolean[100010]; static int n,m,k,sol=0; static long OO = 1000000000000000L ; static HashSet<Integer> hash = new HashSet<Inte...
Java
["5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5", "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3"]
2 seconds
["2", "2"]
null
Java 7
standard input
[ "graphs", "greedy", "shortest paths" ]
03d6b61be6ca0ac9dd8259458f41da59
The first line contains three integers n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ n; ui ≠ vi; 1 ≤ xi ≤ 109). Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109). It is guaranteed that there is at least one ...
2,000
Output a single integer representing the maximum number of the train routes which can be closed.
standard output
PASSED
18044f9ef0c72c4aa58552f063997eb5
train_001.jsonl
1386943200
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is he...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class C { static BufferedReader in; static StringTokenizer st; static PrintWriter out; publ...
Java
["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3"]
1 second
["5", "5"]
null
Java 7
standard input
[ "two pointers", "sortings", "greedy" ]
361f65484d86051fa9ff013f5e8c9154
The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).
1,600
Output a single integer — the optimal number of visible kangaroos.
standard output
PASSED
3e4fb727c990ec0faf1a1a08c5195186
train_001.jsonl
1386943200
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is he...
256 megabytes
import static java.util.Arrays.deepToString; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.uti...
Java
["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3"]
1 second
["5", "5"]
null
Java 7
standard input
[ "two pointers", "sortings", "greedy" ]
361f65484d86051fa9ff013f5e8c9154
The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).
1,600
Output a single integer — the optimal number of visible kangaroos.
standard output
PASSED
0fed5485f9eaaccd433d4a3059455951
train_001.jsonl
1386943200
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is he...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class C_219 { static int[] s; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); s= new int[n]; for(int i = 0; i < n; i++){ s[i] = in.nextInt(); } Arrays.sort(s); //System.out.println(Arrays.t...
Java
["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3"]
1 second
["5", "5"]
null
Java 7
standard input
[ "two pointers", "sortings", "greedy" ]
361f65484d86051fa9ff013f5e8c9154
The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).
1,600
Output a single integer — the optimal number of visible kangaroos.
standard output
PASSED
a71544529d5d9c855ed7a736679e48c6
train_001.jsonl
1386943200
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is he...
256 megabytes
import java.io.*; import java.util.*; public class Main {public static void main(String[] args) throws Exception {new Solve();}} class Solve { public Solve() throws Exception {solve();} static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTo...
Java
["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3"]
1 second
["5", "5"]
null
Java 7
standard input
[ "two pointers", "sortings", "greedy" ]
361f65484d86051fa9ff013f5e8c9154
The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).
1,600
Output a single integer — the optimal number of visible kangaroos.
standard output
PASSED
ac5cfd1b2c3ed0de0251a0c6a3d9efc5
train_001.jsonl
1386943200
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is he...
256 megabytes
//package C; import java.util.Arrays; import java.util.Scanner; public class C { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [] l = new int[n+1]; for(int a=1;a<=n;a++) l[a] = sc.nextInt(); int j = n; int ans = 0; Arrays.sort(l); for(int i = n/2;i>=1&&j>n/2;i--){ if(l[i]*2<=l...
Java
["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3"]
1 second
["5", "5"]
null
Java 7
standard input
[ "two pointers", "sortings", "greedy" ]
361f65484d86051fa9ff013f5e8c9154
The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).
1,600
Output a single integer — the optimal number of visible kangaroos.
standard output
PASSED
e232398f478aefe712d24c2b04062f4f
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class MainD { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1,...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
71727ea0c16991da713fe411343261a2
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class MainD { Scanner sc = new Scanner(System.in); void run() { int n = sc.nextInt(); int[] a = new int[n]; int M = 1000000000; Map<Integer, Integer> map = new HashMap<Integer, In...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
d2d6fe3feec75ff1a947e12bf0c8ba4c
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class MainD { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
df48ac6fdb801470a003dad5c03c34fe
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class MainD { Scanner sc = new Scanner(System.in); void run() { int n = sc.nextInt(); int[] a = new int[n]; int M = 1000000000; Map<Integer, Integer> map = new HashMap<Integer, In...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
97cb1b71ca5ce8d9be758cff590d5132
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.*; import java.util.*; public class d { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = input.nextInt(); int[] as = new int[n]; long oo = (long)2e9+7; for(int i = 0; i<n; i++) as[i] = input.nextInt(); HashSet...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
b698280213e06a053c640c14975bcc65
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); long CC = (long)1e10 + 7; int n = stdin.nextInt(); long[] a = new long[n]; HashSet<Long> set = new HashSet<>(); HashMap<Long, Integer> map = new HashMap<>(); for (int i = 0; i < n; ...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
9307a405896d3c4becbd4d3f51356813
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } int ans = 0; Set<Long> vis = new HashSet<>(...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
aedd65f9d74aef5922ad592842c6da6f
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
//package fibonacci; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class Test { /** * @param args */ static int[] filter(int t[], int size) { int i = 0, r...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
34f637420f531d00e82f162ced14396f
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.*; import java.util.*; public class Solution { private BufferedReader in; private StringTokenizer line; private PrintWriter out; private static final int mm = 1000000007; public void solve() throws IOException { int n = nextInt(); int[] a = nextIntArray(n); ...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
db0b39f0a63cfbe011213d49e7315f2d
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.io.*; import java.util.*; public class ManthanD { private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public s...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
b0a55b8ff29d5681924c2a0b22b3c9af
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; import java.util.Vector; public class D { class Pair { int a, b; public Pair(int a, int b) { this.a = a; ...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
f96964a30ed179650f13d00de9c57e31
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 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.Entry; import java.util.Random; import java.util.TreeMap; public class D { public static void main(String[] args) throws NumberFormatException, IOExce...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
c7f1e2f1c9a2f849cb5b55e698f1e3e7
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class D { public static void main(String [] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
53089de5e22d3ba2ee97fabf4021504d
train_001.jsonl
1456506900
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
512 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchEx...
Java
["3\n1 2 -1", "5\n28 35 7 14 21"]
3 seconds
["3", "4"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
Java 7
standard input
[ "dp", "hashing", "math", "implementation", "brute force" ]
98348af1203460b3f69239d3e8f635b9
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
2,000
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
standard output
PASSED
d3cffb2fce2d19ebd3373346c083fce0
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class a { public static final long oo = (long)2e18; public static void main(String[] args) throws IOE...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
48f015351579bdb6819be90312201171
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class a { public static final long oo = (long)2e18; public static void main(String[] args) throws IOE...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
b6eaf9b3739a8a3fa96249c6f7734f33
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class a { public static final long oo = (long)2e18; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), m = in.nextInt(); long b = in.nextLong(); ...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
2ae807d9a98b56e490e0ef6f477ff6b6
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.Comparator;...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
9fdabb80fa994b5f2ec4ac7c9559fbb5
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class a { public static final long oo = (long)2e18; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), m = in.nextInt(); long b = in.nextLong(); ...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
db4fd49906aa55dd4fc2ec38a0528201
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.Comparator;...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
6f3556f2dca620a7b9421ef169b9620e
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class a { public static final long oo = (long)2e18; public static void main(String[] args) throws IOE...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
8485f1fad5a5fff2230b1d62c3807c0c
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.ArrayList; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; ...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
16910a36263bad66f0fbdf74bbb6decf
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CunningGena { static int[] can, cost; static Pair[] monitor; static int n, m, b; static long inf = (long) 2l * 1000000 * 1...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
7419b40f1c6b4f0aa3b20d2a73459e83
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CunningGena { static int[] can, cost; static Pair[] monitor; static int n, m, b; static long inf = (long) 2l * 1000000 * 1...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
9c75c1ca39cfb18631f9f14e499851ad
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class CunningGena { static int[] can, cost; static int[] monitor; static int n, m, b; static long i...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
bdf9ca75611df187f9b7acf7a27fc641
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CunningGena { static int[] can, cost; static Pair[] monitor; static int n, m, b; static long inf = (long) 2l * 1000000 * 1...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
dac52b17bd99a18c6cef65675db749d1
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.Arrays.fill; import static java.util.Arrays.sort; public class Main{ void run(){ Locale.setDefault(Locale.US); boolean my; try...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
72b2c5d95b1058df5ee238398b71cde0
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.Arrays.fill; import static java.util.Arrays.sort; public class Main{ void run(){ Locale.setDefault(Locale.US); boolean my; try...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
0435ceac752075a765faba9f5a01c6a9
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF418B extends PrintWriter { CF418B() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF418B o = new CF418B(); o.main(); o.flush(); } static final long INF = 0x3f3f3f3f3f3f3f3fL; ...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
c47b47b8f44408ac11c989a0e801019c
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cla...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
f2fe1f1eebe3f0e01443bb7f087086c8
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.*; import java.util.*; public class A { static long []memo; static long INF=(long)1e18; static ArrayList<Integer>[]adj; static long dp(int msk) { if(msk==0) return 0; if(memo[msk]!=-1) return memo[msk]; long ans=INF; int idx=log[msk&-msk]; for(int solve:adj[idx]) { int newMsk...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
7765d6ced1bb4169f1bba02fac9b9a92
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static void solve() throws Exception { int n = nextInt(); int m = nextInt(); int b = nextInt(); Friend[] a = new Friend[n]; for (int i = 0; i < n;...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 8
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
b033a8e929ba9f985377457739ada55a
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CunningGena { static int n, m; static long b; static Friend[] friends; static long[...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 6
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
81d9ea70e6cc208b4d6f98d05892fd54
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class B { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public void solve() throws IOException { int N = nextInt(); int M = n...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 6
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
f5ddbd72af85f3b7f7694b4df60e3c0a
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.util.* ; import java.io.* ; import java.util.regex.* ; import java.text.* ; import java.math.* ; public class Main { public static void main( String[] args ) { InputStream isObj ; OutputStream osObj ; InputReader irObj ; PrintWriter pwObj ; String inputFileName , outputFileName ; File fObj1 , ...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 6
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
65cc09a3dee6d38c3d17861731db09dd
train_001.jsonl
1397749200
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
256 megabytes
import java.io.*; import java.util.*; import java.lang.reflect.*; public class Main { static long CURRENT_TIME_NANO = System.nanoTime(); public static void main(String[] args) throws Exception { int n = next(); int m = next(); long b = nextl(); long[] x = new long[n]; long[] k = new long[n]; int[]...
Java
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
1 second
["202", "205", "-1"]
null
Java 6
standard input
[ "dp", "sortings", "bitmasks" ]
bc5b2d1413efcaddbf3bf1d905000159
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
1,900
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
standard output
PASSED
3335a66d1cd381bd34c49dd6de805d39
train_001.jsonl
1599918300
This is an interactive problem.There is an unknown integer $$$x$$$ ($$$1\le x\le n$$$). You want to find $$$x$$$.At first, you have a set of integers $$$\{1, 2, \ldots, n\}$$$. You can perform the following operations no more than $$$10000$$$ times: A $$$a$$$: find how many numbers are multiples of $$$a$$$ in the curr...
512 megabytes
//package Codeforces.Round670Div2; import java.util.*; public class E { static ArrayList<Integer> primes; /*static class Checker { int n; int guess; boolean finishedflag; ArrayList<Integer> arr; int gcount; Checker(int n, int guess) { thi...
Java
["10\n\n2\n\n4\n\n0"]
1 second
["B 4\n\nA 2\n\nA 8\n\nC 4"]
NoteNote that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.In the first test $$$n=10$$$ and $$$x=4$$$.Initially the set is: $$$\{1,2,3,4,5,6,7,8,9,10\}$$$.In the first operation, you ask how many numbers are multiples of $$$4$$$ and ...
Java 11
standard input
[ "interactive", "number theory", "math" ]
513480a6c7a715e237c3a63805208039
The first line contains one integer $$$n$$$ ($$$1\le n\le 10^5$$$). The remaining parts of the input will be given throughout the interaction process.
2,600
null
standard output
PASSED
a0e91105106b8b650c38f1e9c993adab
train_001.jsonl
1599918300
This is an interactive problem.There is an unknown integer $$$x$$$ ($$$1\le x\le n$$$). You want to find $$$x$$$.At first, you have a set of integers $$$\{1, 2, \ldots, n\}$$$. You can perform the following operations no more than $$$10000$$$ times: A $$$a$$$: find how many numbers are multiples of $$$a$$$ in the curr...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1406e { public static void main(String[] args) throws IOException { int n = ri(), div[] = new int[n + 1], sqrt = (int) sqrt(n); List<Integer> primes = new ArrayList<>(); ...
Java
["10\n\n2\n\n4\n\n0"]
1 second
["B 4\n\nA 2\n\nA 8\n\nC 4"]
NoteNote that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.In the first test $$$n=10$$$ and $$$x=4$$$.Initially the set is: $$$\{1,2,3,4,5,6,7,8,9,10\}$$$.In the first operation, you ask how many numbers are multiples of $$$4$$$ and ...
Java 11
standard input
[ "interactive", "number theory", "math" ]
513480a6c7a715e237c3a63805208039
The first line contains one integer $$$n$$$ ($$$1\le n\le 10^5$$$). The remaining parts of the input will be given throughout the interaction process.
2,600
null
standard output
PASSED
38278f064a1b66a4fd28764488d8ccac
train_001.jsonl
1599918300
This is an interactive problem.There is an unknown integer $$$x$$$ ($$$1\le x\le n$$$). You want to find $$$x$$$.At first, you have a set of integers $$$\{1, 2, \ldots, n\}$$$. You can perform the following operations no more than $$$10000$$$ times: A $$$a$$$: find how many numbers are multiples of $$$a$$$ in the curr...
512 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.Closeable; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; ...
Java
["10\n\n2\n\n4\n\n0"]
1 second
["B 4\n\nA 2\n\nA 8\n\nC 4"]
NoteNote that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.In the first test $$$n=10$$$ and $$$x=4$$$.Initially the set is: $$$\{1,2,3,4,5,6,7,8,9,10\}$$$.In the first operation, you ask how many numbers are multiples of $$$4$$$ and ...
Java 11
standard input
[ "interactive", "number theory", "math" ]
513480a6c7a715e237c3a63805208039
The first line contains one integer $$$n$$$ ($$$1\le n\le 10^5$$$). The remaining parts of the input will be given throughout the interaction process.
2,600
null
standard output
PASSED
5f41e8613b5e1c2362e1367fa92b0e81
train_001.jsonl
1599918300
This is an interactive problem.There is an unknown integer $$$x$$$ ($$$1\le x\le n$$$). You want to find $$$x$$$.At first, you have a set of integers $$$\{1, 2, \ldots, n\}$$$. You can perform the following operations no more than $$$10000$$$ times: A $$$a$$$: find how many numbers are multiples of $$$a$$$ in the curr...
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.Arrays; import java.util.HashSet; import java.util.StringTokenizer; public class problemE { static final int MAXN = 1_000_00; static ArrayList<In...
Java
["10\n\n2\n\n4\n\n0"]
1 second
["B 4\n\nA 2\n\nA 8\n\nC 4"]
NoteNote that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.In the first test $$$n=10$$$ and $$$x=4$$$.Initially the set is: $$$\{1,2,3,4,5,6,7,8,9,10\}$$$.In the first operation, you ask how many numbers are multiples of $$$4$$$ and ...
Java 11
standard input
[ "interactive", "number theory", "math" ]
513480a6c7a715e237c3a63805208039
The first line contains one integer $$$n$$$ ($$$1\le n\le 10^5$$$). The remaining parts of the input will be given throughout the interaction process.
2,600
null
standard output
PASSED
50085779aa0eed08fd8cf5dc8e2836b4
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author @thnkndblv */ public class ...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
4580c289d25029da7efc35e82d6b1638
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public final class football { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); public static void main(String args[]) throws Exception { int n...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
b054d30dd2512399cf460946241f6233
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import static java.util.Arrays.*; import static java.lang.Math.*; import static java.util.Collections.*; import static java.lang.System.out; public class Main { static boolean LOCAL = System.getSecurityManager() == null; Scanner in = new Scanner(System.in); ...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
83783b8c4420caa1bc399f060de6076a
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import static java.util.Arrays.*; import static java.lang.Math.*; import static java.util.Collections.*; public class Main { static boolean LOCAL = System.getSecurityManager() == null; Scanner in = new Scanner(System.in); static PrintWriter out = new PrintW...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
17f29f438f9164897815bfc7ecf79389
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Locale; import java.util.StringTokenizer; public class RCC_A { static StringTokenizer st; static BufferedReader b...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
7509e92272ad0d49257fc0deee828f4a
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Exercise3 implements Runnable { static BufferedReader in; static PrintWriter out; static StringTokenizer st; private void solve() thr...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
b0906b0f7939e16ab34a90e7e50c942c
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; i...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
e29b6ce3293a6254a7e11dd847202192
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class C { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); PrintWriter wrt = new PrintWriter(System.out); int n = scan.nextInt(); int k = scan.n...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
591e68b209cf570b1dc3a89f1b09e786
train_001.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws IOException { (new Main()).solve(); } public Main() { } MyReader in = new MyReader(); PrintWriter out = new PrintWriter(System.out); void solve(...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
9455e7bfdb5fc09aea8c22d6b915567f
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import java.io.*; public class coverit { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int n = sc.nextInt(); while(n-->0) { int x = sc.nextInt(); int y = sc.nextInt(); graph g = new...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
1d5abac5b8a8469e54441c392d91fc71
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); PrintWriter out = new PrintWriter(System.out); for ...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
200bb2d8d9ea3a81c1951d0e4b397f40
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader in = new Reader(); int t = in.nextInt(); PrintWriter out = new PrintWriter(System.out); for (int test = 0; test < t; test++) { int nodes = in.nex...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
274d0178adea9abf4ce3488fd505e778
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
/* *created by Kraken on 05-05-2020 at 12:40 */ //package com.kraken.cf.practice; import java.util.*; import java.io.*; public class E1176 { private static ArrayList<ArrayList<Integer>> graph; private static int n, m, o, e; private static boolean[] vis; private static int[] dis; private static StringBuild...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
79ef5002560686b10ed1fb2bbc25222b
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import static java.util.Arrays.* ; import static java.lang.Math.* ; import java.util.*; import java.io.*; public class A { int [][] adjList ; void main() throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int TC = sc.nextInt() ; ...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
cb1c8e3a4616adb6ab793c219d76acd5
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import static java.util.Arrays.* ; import static java.lang.Math.* ; import java.util.*; import java.io.*; public class A { int [][] adjList ; void main() throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int TC = sc.nextInt() ; ...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
4bfb8a2c7ada71af7a9aace2ebb49e97
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; public class E1176 { private static class Node { long h; HashMap<Integer,Long> edges = new HashMap<Integer...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
879a1a127bbd67f7f52ae123ad610853
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj = {0, -1, 1, 0}; static int ...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
adac171e8ece81ffec5ead4eed0d648b
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj = {0, -1, 1, 0}; static int ...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
de9844c8dc20ef6c45250b7ffa69c88e
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { static PrintWriter out=new PrintWriter(System.out);static FastScanner in = new FastScanner(System.in);static class FastScanner {BufferedReader br;StringTokenizer stok;FastScanner(InputStream is) {br = new BufferedReader(new InputStr...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
f08a4248968bbae80b4c0c37734d9130
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class cf1 { static long mod = (long)1e9 + 7; static long mod1 = 998244353; static FastScanner f; static PrintWriter pw = new PrintWriter(System.out); static Scanner S = new Scanner(System.in); static long x0; static long y...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
ac0cc879c7bdec49805d76b4fa7a1d64
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class codeforces { public static void main(String[] args) throws IOException { BufferedReader scan = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); int t = Intege...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
384b9f2cccce1de555e8114aa80f4d0c
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class round565d3e { private static StringBuilder sb; public static void main(String args[]) { FastScanner in = new FastScanner(System.in); sb = new StringBuilder(); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt();...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
b30b8990edd255aed65490566dba7aa9
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.*; import java.util.*; public class Solution { //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; //-----------MyScanner class for faster input---------- public static class MyScanner { BufferedReader br; StringTok...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
df02079c20dc0facf88d8ce623a5210f
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; public class Solution { static class Node { int index; int color = -1; List<Node> neighbour = new ArrayList<>(); public Node(int index) { this.index = index; } } public static void main(String[] args) { Scanner scan = new Sc...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
837802c742df8e9984467e837ae50032
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.LinkedList; import java.util.Queue; public class E565 { public static void main(String[] args) { FastScanner in = new FastScanner(System.in); i...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
a1f59aa0a1d68e867b90776f292a8081
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Scanner; import java.util.StringTokenizer; public class TaskD { public static void main(String[] args) throws IOEx...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
226a2ca4d9c5866dc0d26db93489861e
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import javax.lang.model.util.ElementScanner6; import java.io.*; public class Main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWrite...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
1df8e47b51935b6a95f87ba303392160
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.*; import javax.lang.model.util.ElementScanner6; import java.io.*; public class Main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
b4dbec687628fb6600e08c00f9f150d1
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); StringBuilder builder = new StringBuilder(); for(int i = 0; i < n; i++) { test(stdin, b...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
17527c8b6cd8537abf85da86990f5320
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { StringBuilder builder = new StringBuilder(); Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); for(int i = 0; i < n; i++) { test(stdin...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
297964006c8d3c4c9bad84b59427a549
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { StringBuilder builder = new StringBuilder(); Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); for(int i = 0; i < n; i++) { test(stdin...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
f4fcca1880db3c28803c56903e293333
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Iterator; import java.util.Collection; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; im...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
ecb5006fd43f2e2ef32cc7fbf0bd09e9
train_001.jsonl
1560090900
You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to choose at most $$$\lfloor\frac{n}{2}\rfloor$$$ vertices in this graph so each unchosen vertex is adjacent (in other ...
256 megabytes
import javax.swing.event.TreeSelectionEvent; import java.io.*; import java.util.*; public class Main { static long gcd(long a, long b) { return a == 0 ? b : gcd(b, b % a); } static long binpow(long a, int n) { return n == 1 ? a : (n & 1) == 0 ? binpow(a, n / 2) * binpow(a, n / 2) : a * bi...
Java
["2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n6 8\n2 5\n5 4\n4 3\n4 1\n1 3\n2 3\n2 6\n5 6"]
2 seconds
["2\n1 3\n3\n4 3 6"]
NoteIn the first query any vertex or any pair of vertices will suffice. Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices $$$2$$$ and $$$4$$$) but three is also ok.
Java 8
standard input
[ "graphs", "shortest paths", "dsu", "dfs and similar", "trees" ]
c343e6a298c12cb1257aecf823f2ead0
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of queries. Then $$$t$$$ queries follow. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$n - 1 \le m \le min(2 \cdot 10^5, \frac{n(n-1)}{2})$$$) — the number of verti...
1,700
For each query print two lines. In the first line print $$$k$$$ ($$$1 \le \lfloor\frac{n}{2}\rfloor$$$) — the number of chosen vertices. In the second line print $$$k$$$ distinct integers $$$c_1, c_2, \dots, c_k$$$ in any order, where $$$c_i$$$ is the index of the $$$i$$$-th chosen vertex. It is guaranteed that the ans...
standard output
PASSED
4606ae74806a6b492999aca1a4159dc8
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; /* * @author: Ramanqul * */ public class Main { private static boolean USE_TEST_CASES = false; private static void solve(MyScanner in, PrintWriter out) { int n = in.nextInt(); int k = in.nextInt(); int a[][] = new int[n][2]; for (int i=0;...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
84b5efe3e03d1a42c568d74fc5a5e37d
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class JavaApplication2 { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int n=reader.nextInt(); int k=reader.nextInt(); int total=0; for(int i=0;i<n;i++){ int min=reader.nextInt();...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
f447b7a51a65bb2af6f610b58c09dcff
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(); int sum = 0; for(int i = 0 ; i < n; i++) sum += -(sc.nextInt() - sc.nextInt()) + 1; System.out.println((k - sum%k) % k); sc.clo...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
d0670904c225c150e17e32cd2471e3ce
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int covered = 0; for(int i=0;i<n;i++){ int l = in.nextInt(); int r = in.nextInt();...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
8f278d2c56694626c5e586b0e8da0640
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int sum = 0; while(n-- > 0) { int l = s.nextInt(); int r = s.nextInt(); su...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
5a9098b0b25d70c812a9665b910b1b2a
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
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 k = scan.nextInt(); int o = 5%2; int c = 0; for (int i = 0; i < n; i++) { int n1 = scan.nex...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
769531b7ab7ccde457e8cf523586d788
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PenguinSegments { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); int covered = 0; for (int i = 0; i < n; i++) { int start = scanner....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
1f823632f5e3f1cb259510387d67c7cc
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Sol { static FastReader reader = new FastReader(); /** * #### * .#.. * #### * .... */ public static void main(String[] args) { int n = reader.nextInt(); int k = reader.nextInt(); int su...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
963e80d023de14a1974457b98e5fe65c
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.Iterator; import java.util.LinkedList; import j...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7e444f00b7592fd9869dfbcead8c3fe0
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public final class Solution { public static void main(String[] args) { Reader input = new Reader(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = input.nextInt(), k = input.nextInt() , a , b; ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7938b118a4ed96a4e861ce9c06121e75
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public final class Solution { public static void main(String[] args) { Reader input = new Reader(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = input.nextInt(), k = input.nextInt() , a , b; ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
c851ee163ba1f8f20b9a2e32e4b215ba
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; public class PolothePenguinandSegments { public static void main(String[] args) { Scanner in= new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); int[] arr=new int[2*n]; int nint=0; for(int i=0;i<arr.length;i+=2) { int l=in.nextInt(); int r=in.nextInt(); nint+=(r-l...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
92d942bf7f9e42ac6d3d3a1d833cc477
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
//package polo.the.penguin.and.segments; import java.util.Scanner; public class PoloThePenguinAndSegments { private static int count=0, numberBetween,j = 0; public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
5aefbfdb905eeb9b01542042495ac319
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
//package polo.the.penguin.and.segments; import java.util.Scanner; public class PoloThePenguinAndSegments { private static int count=0, numberBetween,j = 0; public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
98fddab8a8dbab658a8c32c79b771c0f
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
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
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output