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
636a70f76d8fcba8fdbc170cd2926ab2
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); String str = br.readLine(); StringTokeniz...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
cfb1b8792070d930a0687ec5eb9d8d0c
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class cdf508a { static void merge(int arr[], int l, int m, int r) { int n1 = m - l + 1; int n2 = r - m; int L[] = new int [n1]; int R[] = new int [n2]; for (int i=0; i<n1; ++i) ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
d881650ce527f10e379d5e6fb77d4ebc
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.*; import java.io.*; public class Param { public static void main( String[]args) { MyScanner param = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n=param.nextInt(); int k=param.nextInt(); char []arr=new ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
b491582173ef4d8139dc0b43843c1e90
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.*; import java.util.InputMismatchException; import java.util.Scanner; import java.util.stream.Collectors; /** * https://codeforces.com/contest/1038/problem/A */ public class Solution1038A { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); // I...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
db5d4869c5a46db41617e9da8421161a
train_003.jsonl
1525007700
One department of some software company has $$$n$$$ servers of different specifications. Servers are indexed with consecutive integers from $$$1$$$ to $$$n$$$. Suppose that the specifications of the $$$j$$$-th server may be expressed with a single integer number $$$c_j$$$ of artificial resource units.In order for produ...
256 megabytes
import java.io.*; import java.util.*; public class VK_B implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader("input.txt")); out =...
Java
["6 8 16\n3 5 2 9 8 7", "4 20 32\n21 11 11 12", "4 11 32\n5 5 16 16", "5 12 20\n7 8 4 11 9"]
2 seconds
["Yes\n3 2\n1 2 6\n5 4", "Yes\n1 3\n1\n2 3 4", "No", "No"]
NoteIn the first sample test each of the servers 1, 2 and 6 will will provide $$$8 / 3 = 2.(6)$$$ resource units and each of the servers 5, 4 will provide $$$16 / 2 = 8$$$ resource units.In the second sample test the first server will provide $$$20$$$ resource units and each of the remaining servers will provide $$$32 ...
Java 8
standard input
[ "sortings", "binary search", "implementation" ]
aa312ddd875b82eab84fdc92ceec37e5
The first line contains three integers $$$n$$$, $$$x_1$$$, $$$x_2$$$ ($$$2 \leq n \leq 300\,000$$$, $$$1 \leq x_1, x_2 \leq 10^9$$$) — the number of servers that the department may use, and resource units requirements for each of the services. The second line contains $$$n$$$ space-separated integers $$$c_1, c_2, \ldot...
1,700
If it is impossible to deploy both services using the given servers, print the only word "No" (without the quotes). Otherwise print the word "Yes" (without the quotes). In the second line print two integers $$$k_1$$$ and $$$k_2$$$ ($$$1 \leq k_1, k_2 \leq n$$$) — the number of servers used for each of the services. In...
standard output
PASSED
0f7f935f90b2a05bf45106cbd8c69d55
train_003.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 11
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) —the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≤ ai ≤ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
f0e38d3c47de83a50f18fa5c552340ed
train_003.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static Reader in = new Reader(); public static void main(String[] args) throws IOException { Main solver = new Main(); solver.solve(); out.flush(); ...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 11
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) —the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≤ ai ≤ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
2573e6ac5aadc5f00314d81e4f3a43e7
train_003.jsonl
1511449500
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai &gt; 0, then ai bourles are deposited to Luba's account. If ai &lt; 0, then ai bourles are withdrawn. And if ai = 0...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long MOD=(long) (1e9+7); public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(...
Java
["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0"]
2 seconds
["0", "-1", "2"]
null
Java 11
standard input
[ "dp", "implementation", "greedy", "data structures" ]
c112321ea5e5603fd0c95c4f01808db1
The first line contains two integers n, d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) —the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≤ ai ≤ 104), where ai represents the transaction in i-th day.
1,900
Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.
standard output
PASSED
8d059e84335e7621b99000df4aa479ba
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream;...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
f69b8884a7157fc0761bd5a461683759
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner nik = new Scanner(System.in); int n = nik.nextInt(); HashMap<Integer, HashSet<Integer>> ht = new HashMap<>(); int[][] a = new int[n][2]; for (int i = 0; i < n...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
bda6e647428912fdd17610a3fceceec8
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class R628C { public static void main(String[] args) throws Exception { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); int N=Integer.parseInt(in.readLine()); List<List<Integer>> //neighbors=new ArrayList<>(), ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
2482d26e1c772fc83a14abd19699e265
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
/* [ ( ^ _ ^ ) ] */ import java.io.*; import java.util.*; public class test { int INF = (int)1e9; long MOD = 1000000007; void solve(InputReader in, PrintWriter out) throws IOException { int n = in.nextInt(); int[][] e = new int[n-1][2]; int[] deg = new int[n]; for(in...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
aa38f0f446914caa7e946779e6560435
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
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 n = Integer.parseInt(in.readLine()); int[] v = new int[n+1]; int node = 0; boolean done = false; ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
788a5e47746e9b58765b9f7b4a8a4fc4
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String args[])throws IOException { FastReader in=new FastReader(System.in); int i,j; int fg=0; //long min=Long.MAX_VALUE; //long ma...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
bc15d493ff89d2860689efce738635ef
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class C628_PC { public static ArrayList<pair>[] adj; public static int n; public static int[] ans; public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader in = new BufferedReader(new InputStreamReader(System.in));...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
92c313ec3ed6588be992e67803b80fa4
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
86819d3eb98f17587fc4d6009a0f9e3f
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.awt.List; 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.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Stri...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
ef165519e1c180824303faf09ebfe700
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.LinkedList; import java.util.Set; import java.util.StringTokenizer; public class C { static int ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
bcedb0bf3fc0dd04f1a4e799e311cc61
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class TaskC { private static ArrayList<ArrayList<Integer>> adj = new ArrayList<>(); private static HashMap<Edge, Integer> edges = new HashMap<>(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new Inp...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
68d25c92e5d5d3a9c9079f3e2f0d1ef9
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable{ FastScanner sc; PrintWriter pw; final class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(Syste...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
49a959e5160fd750d96e276cd836598a
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), tree[][] = new int[n - 1][2], occur[] = new int[n], ans[] = new int[n - 1]; for (int i = 0; i < n - 1; i++) { int x = in.nextInt() - 1, y = in.nextInt() - 1; tree[i][...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
6952b78f61f998ba9613005f6d8f7720
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class ehab_mex { public static void main(String[...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
9d35c6e924323c31b2f399acd1ba3a0a
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
//package com.company; import java.io.*; import java.util.*; import java.lang.*; public class Main{ public static class FastReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
853bdc657a8721a7702809edbbb1c6fe
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCh...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
5e13ec50dcfca6ac6639a4cc4b43d444
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.Stack; public class minjumps{ public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
d2b90d7363e79c25e5dbcdfd8282fd66
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * Pick questions that you love and solve them with love, try to get AC in one * go with cleanest code Just one thing to keep in mind th...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
9589c4439a2a5d144b99d7067f49b21d
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn=new Scanner(System.in); int n =scn.nextInt(); int [][] arr =new int[n-1][2]; for(int i=0;i<n-1;i++){ arr[i][0]=scn...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
69cf905a465bd15f175b9ee08a8ac45d
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; public class DIV2C_Ehab_and_Path_etic_MEXs { private static final StreamTokenizer IN = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); private static final PrintWriter OUT = new PrintWriter(new O...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
5a957670ebc0738783d2d86a1bf112ca
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
// package codeForces; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.io.*; import java.math.*; import java.text.*; public class TEhabPatheticMEXs { static InputReader in = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
5c70a2b0eb9c7cf85191e87dfecd3ca7
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
//package learning; import java.util.*; import java.io.*; import java.lang.*; import java.text.*; import java.math.*; import java.util.regex.*; public class NitsLocal { static ArrayList<String> s1; static boolean[] prime; static int n = (int)1e7; static void sieve() { Arrays.fill(prime , true); pr...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
faad4c03a254427fee3ef32130be7599
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class TaskC { public static void main(String[] args) throws Exception { BufferedReader br = new Buff...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
3aa6ddcd5f48001f4bdd77954b99f6be
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class MyClass { public static void main(String args[]) { FastReader sc = new FastReader(); //For Fast IO int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); ArrayList<Integer> adj[] = new ArrayList[n+1]; int ans[] = new in...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
d0fe9a35673f39f60289a43aea24089d
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class MyClass { public static void main(String args[]) { FastReader sc = new FastReader(); //For Fast IO int n = sc.nextInt(); ArrayList<Integer> adj[] = new ArrayList[n+1]; int ans[] = new int[n+1]; Arrays.fill(ans,-1); for(i...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
877c1eef3c8bfa8d85c8afa8222592ec
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; import java.util.Random; import...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
17e4fdd92c3cfbee4b1571af7b220cdd
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.*; public class code2 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } S...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
9e5030a3fccc04b5501d0952f9e23230
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.*; import java.util.*; public class tryyy { static public class pair { int u; int idx; int val; public pair(int x, int i) { u = x; idx = i; val = -1; } } static public class trp implements Comparable<trp> { ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
70462b79d108f8d856ba443a891234dd
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.InputMismatchException; import java.util.TreeMap; public class C { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub ...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
d158ae2ff23cc68e038796d89bd447e1
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.*; public class EhabAndPatheticMEXs { public static void main(String[] args) throws IOException{ Scan S = new Scan(); Print P = new Print(); int N, u, v; N = S.scanInt(); List<List<Integer>> graph = new ArrayList<>(Collections.nCopies(N+1, n...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
23192755596cd36df66f0f42e0d679fa
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import sun.reflect.generics.tree.Tree; import java.lang.reflect.Array; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int []a=new int[n+1]; int []b=new int[n+1]; int c[][]=new int[n...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
aa457d5f2b779e79a4456ae13e5dc2ba
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static void main (String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); String[] temp=br.readLine().trim().split(" "); int n=Integer.parseInt(te...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
60a898d64f0779b95f710d603529a6e7
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class test2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); ArrayList<ArrayList<Integer>> adjmat = new ArrayList<ArrayList<Integer>>(); TreeMap<Integer, T...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
60827ba5b1f9301dde6d07432f9cae0e
train_003.jsonl
1584196500
You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive. All the written labels are distinct. The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class r628c { public static void main(String[] args) { //solution idea: pr...
Java
["3\n1 2\n1 3", "6\n1 2\n1 3\n2 4\n2 5\n5 6"]
1 second
["0\n1", "0\n3\n2\n4\n1"]
NoteThe tree from the second sample:
Java 8
standard input
[ "constructive algorithms", "greedy", "dfs and similar", "trees" ]
5ef966b7d9fbf27e6197b074eca31b15
The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is ...
1,500
Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).
standard output
PASSED
2a5b2caf818dad30401b38372cf268f1
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; import java.math.*; import java.text.*; import java.util.*; //Codeforces public class MainCodeforces1 { private static MyScanner in; private static PrintStream out; public static void main(String[] args) throws IOException { // helpers for input/output boolean LOCAL_TEST = false;// change to ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
bfb34e576884b44412e7b0a9e4c35ec8
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
/* PROG: b LANG: JAVA */ import java.util.*; import java.io.*; public class c { int n, k; private void solve() throws Exception { //BufferedReader br = new BufferedReader(new FileReader("c.in")); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer sc = new ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
bdf945a0212e71e2be70d17438e1cfb3
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
/* PROG: b LANG: JAVA */ import java.util.*; import java.io.*; public class c { int n, k; private void solve() throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer sc = new StringTokenizer(br.readLine()); n = Integer.parseInt(sc.nextToken...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
6f04f9138565d088a9e0a8179083f191
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.TreeSet; public class C { /** * @param args */ public static void main(String[] args) { KDivisibility kd = new KDivisibility(); kd.solve(); kd.print(); } } class KDivisibility { KDivisibility() { ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
2b41bb70da53972460cccac3610d6dba
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; public class B { static int N; static PrintWriter out; public static void main(String[] args) { MScanner sc = new MScanner(); out = new ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
d50462ab511ba12d98c52ccbf741a79d
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.Collections; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Set; public class Round168ProblemC { public static void main(String[] args) { Reader ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
2fcb5f6de51a07d49297e4f07503208d
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solve { public static void main(String[] args) throws FileNotFoundException { //Scanner in = new Scanner(new FileReader("input.txt")); Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); long[] a = new long...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
8199d0e748295e1611df77eda6213057
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class Maain implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
8dda9d5a38ec5f3fcbf1926866dd67c5
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; import java.util.TreeSet; public class C { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanne...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
1040bb5cde59272e54ade8a78143eaa5
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R168_Div2_C //Name: k-Mulitple Free Set { FastReader in; PrintWriter out; public static void main(String[] args) { new R168_Div2_C().run(); } void run() { i...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
49b872bdc092e98cf6edff15461ba2dc
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R168_Div2_C //Name: k-Mulitple Free Set { FastReader in; PrintWriter out; public static void main(String[] args) { new R168_Div2_C().run(); } void run() { i...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
d39d43afe58c746b76384855e26d538b
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.sql.Array; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.TreeSet; import java.util.Scanner; import org.omg.CORBA.ARG_OUT; public class CodeforcesRound168C { public static void main(String[] args) { ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
f8ae6479cc62739a6ecb1a3ff231379b
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.MathContext; import java.util.Arrays; import java.util.HashSet; import java.util.StringTokenizer; public class A { ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
0d1b5d2eeacf5b0790b3f27e7aaa7a56
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class C { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); TreeSet<Integer> hax = new TreeSet<>(); Integer[] list = new Integer[N...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
0da0b414d87960fd639d3259a2eb8db3
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class C { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); TreeSet<Integer> hax = new TreeSet<>(); int[] list = new int[N]; for...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
b7ecfde86f0e8f69401b780173095151
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Task { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); /** * ######################## * Solution */ int n = sc.nextInt(); int k = sc.nextInt...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
1a6a124017f50a35a86a50022cc3d65d
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
768f1a1db5e2b8c5e4bfd6d3edd70035
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.TreeSet; public class C2 { public static void main (String args[]){ Scanner in = new Scanner(System.in); TreeSet<Long> t = new TreeSet<Long>(); int n = in.nextInt(); int k = in.nextInt(); int a[] = new int[n]; for(int i = 0 ; i<n ; i++){...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
3f04dcd560586cdc9eeb1facc6ca017e
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class C { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt();long k = sc.nextLong(); long[] a = new long[n]; boolean[] used = new boolean[n]; ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
d01b0eabd9e0ffc936ed448da46735ef
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class C { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt();long k = sc.nextLong(); long[] a = new long[n]; boolean[] used = new boolean[n]; ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
a20dcef1a58c373156a8a64056274f1d
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class C { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt();long k = sc.nextLong(); long[] a = new long[n]; boolean[] used = new boolean[n]; ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
a449ed6c72d54f741d239870de75b1ae
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.util.Arrays; import java.util.BitSet; import java.util.Scanner; public class Main { Scanner sc = new Scanner(System.in); void run() { int n = sc.nextInt(); int k = sc.nextInt(); int list[] = new int[n]; for (int i = 0; i < n; i++) { list[i] = sc.nextInt...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
2a83de01719910cbaa1d0bea6012dad1
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeSet; public class C { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); int n = myScanner.nextInt(), k = myScanner.nextInt(); myScanner.nextLine(); StringTokenizer t...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
927cbc6be960c6c903968785a63080f4
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class C { public static void main(String [] args){ Scanner cin = new Scanner(System.in); PrintWriter cout = new PrintWriter(System.out); int N = cin.nextInt(), k = cin.nextInt(); int []a = new int[N]; for (int i=0;i<N;++...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
4bfd9c2766781e7fab321c8cbc5bab78
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main { static final String FILE_NAME = ""; static final String INPUT_FILE = FILE_NAME + ".in"; static final String OUTPUT_FILE = FILE_NAME + ".out";...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
aae5c8ec22a1808973e5bd51ea6a1037
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class kMultipleFreeSet { public static void main(String[] args) throws IOException { br = new Buffered...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
38a5d84d125806a0414fd578ff112baf
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.PriorityQueue; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHe...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
03b804975fd34d351308d02dc5184513
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { /** * @param args */ /* public static boolean contains(int a, int b, int c, int d) { return(c>= a && d <= b); } public static boolean isConvex(boolean[][] A) { ...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
6c89a56f2b5f46dd524f67e5d555e781
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; i...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
dc341e127b19f26ac59810c80481ca4a
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.util.Arrays; import java.io.PrintWriter; import java.util.HashSet; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author mdonaj */ public class Main { public static void...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
03857da9529da1eb4c0e9fae6a0279cc
train_003.jsonl
1361374200
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x &lt; y) from the set, such that y = x·k.You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-m...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.Arrays; /** * * @author user */ public class Con168_3 { public static void main(String[] args) thro...
Java
["6 2\n2 3 6 5 4 10"]
2 seconds
["3"]
NoteIn the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Java 7
standard input
[ "binary search", "sortings", "greedy" ]
4ea1de740aa131cae632c612e1d582ed
The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). All the numbers in the lines are separated by single spaces.
1,500
On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.
standard output
PASSED
9dc491a61f394e6de2d76870f6e7ce59
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class TwoSubstrings { public static void main(String args[]) throws Exception { BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader s = new BufferedReader(new FileReader("*.in")); //PrintWriter out = new PrintW...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
4bd1410e32bf59235c1bd45ec81a94a1
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
//package javaapplication43; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan =new Scanner(System.in); String str=scan.nextLine(); boolean flag1=false; boolean flag2=false; boolean flag3=false; boolean flag4=false; ...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
02a2390d994a5dfa2ed57f7cffebb3fe
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; /** * * @author a.sherif */ public class CodeForce { public static void main(String[] args) { Scanner input = new Scanner (System.in); String s = input.next(); int a = s.indexO...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
cc34deac4c9341a26582c4633f3b8996
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
// 09/06/20 3:26 AM Jun 2020 import java.util.Scanner; public class _550A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); if (s.contains("AB") && s.substring(s.indexOf("AB") + 2).contains("BA") || s.contains("BA") && s.substring(s....
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
5b50bf884adf889bd4d1d84e14ace337
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.util.*; public class TwoSubstrings { public static void main(String[] args) { String s = new Scanner(System.in).next(); if(s.contains("AB") && s.replaceFirst("AB", "*").contains("BA")) System.out.println("YES"); else if (s.contains("BA") && s.replaceFirst("BA", "*").contains("AB")) System.out...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
3bde7d65820724ae58165e589ffb42a0
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.util.Scanner; public class oveerlap { public static void main(String[] args) { Scanner ss = new Scanner (System.in) ; String s = ss.next() ; boolean f1 = false ; boolean f2 = false ; String t = "" ; int c = 0 ; int f = 0 ; int g = 0 ; String s2 =s ; boolean c1 = s.contains("AB"...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
e3b4a92c2a59b395fcc0e04c01f05896
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solution { private static boolean needFileIO = false; public static void main(String[] args) { InputStream is = System.in; if (needFileIO) { try { is = new FileInputStream("in"); //os = new FileOutputStream("out"); } catch (...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
8a236488271b1fc0e99c82e1e258a7f8
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class P550A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String word = br.readLine(); if (word.contains("AB")) { Str...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
0558e5c7fcba493db77dc2ad7f1e0062
train_003.jsonl
1433435400
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.util.TreeSet; import java.io.Writer; import java.math.BigInteger; import ja...
Java
["ABA", "BACFAB", "AXBYBXA"]
2 seconds
["NO", "YES", "NO"]
NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA".
Java 8
standard input
[ "dp", "greedy", "implementation", "brute force", "strings" ]
33f7c85e47bd6c83ab694a834fa728a2
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
1,500
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
standard output
PASSED
c504fc6c4c1951a460327519da2471a5
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int[] zarray(String s) { int []z = new int[s.length()]; int l = 0, r = 0; // z[0] = 1; for (int i = 1; i < s.length(); i++) { if (i <= r) { z[i] = min(r - i + 1, z[i - l]); } while (i + z[i] < s.length() && s.charAt(i + z[i]) == s.c...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
3b359fd4fac534daef20261058e19ad6
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
8eeb75dc0befd89b2b474ab3fa7e7358
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.io.*; public class D432 { public static void main(String[] args) { Reader in = new Reader (); String s = in.next(); Solver t = new Solver (s); t.process(); } static class Solver { char [] s; int [] p; ArrayList <Integer> g[]; boolean can []; int count[]; int sub ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
ee199323506403f4e4f61a0dd6a24271
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamRea...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
be71aceefe712c73ca75a5d68a3d55e0
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; public class d1 extends PrintWriter { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); // static Scanne...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
39e2147c051eabb7d3b658e6c0df3daa
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.TreeMap; /** * Created by omar on 11/11/17. */ public class Main { static class SuffixAutomaton { int[] link, len; long[] occ; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
82516ab14885a5978d6a2c6d9db5723b
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
//package a2oj; import java.io.*; import java.util.*; public class PrefixesAndSuffixes{ // ------------------------ public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // ------------------------ char[] s = sc.nextLine().toCh...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
dfa5e8dac208c5ec6f6df7cf020cdf7e
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (root == null || !root....
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
828cb75bd1bcf9c35f19c53ff2f54c72
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int[] prefixFunction(char[] s) { int n = s.length, pi[] = new int[n]; for (int i = 1, j = 0; i < n; ++i) { while (j > 0 && s[i] != s[j]) j = pi[j - 1]; if (s[i] == s[j]) ++j; pi[i] = j; } return pi; } static int[] zAlgo(char...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
22d6860fb5e3049994f675b4db9c5d99
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
94cab8dc4b133adf537ca570961a1e6b
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class CF432D { class Prefix { int l, c; public Prefix(int ll, int cc) { l = ll; c = cc; } public String toString() { return String.format("%d %d", l, c); } } int[] zValues(char[] s) { int n = s.length, L = 0, R = 0; int[] z = new int[n]; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
a57794b965b62696eb25d22c0a7f3126
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class CF432D { final int MAX = 200000; final int ALPHA = 26; int sz, last, len[], link[], trie[][]; boolean[] terminal; void suffixAutomaton(char[] s) { sz = 1; last = 0; len = new int[MAX]; link = new int[MAX]; trie = new int[ALPHA][MAX]; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
26e27028051dfcfe34a4a8d7c626c9ae
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
//Codeforces // 432-D PrefixesandSuffixes import java.util.*; import java.io.*; public class Solution { public static int[] getZArr(String s) { int[] z = new int[s.length()]; int l = 0, r = 0; for (int i = 1; i < s.length(); i++) { // if within the window boundary ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
d695a313516e2182f3bf72e8303b06f7
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
255364883216d59a081bbfb3be98eb31
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
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.StringTokenizer; public class _PrefixesAndSuffixes_432D { static in...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
1d1470c0359b513151c770535aff496a
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn Agrawal coderbond0...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
68a655a98ece0c99d36bf463be87bab7
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class prefixSuffix { public static void main(String[] args) { FastScanner scan=new FastScanner(); Pri...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
34050511ed1120bf417ea6f2dbf58e7c
train_003.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output