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
f4a10a561661e2e65025ec0ddabeaaa8
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.io.InputStream; import java.util.ArrayList; /** * Built using CHelpe...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
3d6cabb5bdb356f1ec2a4ff8128e41f5
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.io.InputStream; import java.util.ArrayList; /** * Built using CHelpe...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
6162f1a2785d0264f4dd03c5b7d6cbd9
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.io.InputStream; import java.util.ArrayList; /*...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
539d1609169c56c61c00f7955258f2bd
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Forces{ public static PrintWriter cout; public static boolean[] visited; public static int ans=0; public static void main(String ...arg) throws IOException { Read cin = new Read(); //InputReader cin = new Inpu...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
79e9723166e3e4356ed1f9566913c961
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; public class A implements Runnable{ final static Random rnd = new Random(); // SOLUTION!!! // HACK ME PLEASE IF YOU CAN!!! // PLEASE!!! // PLEASE!!! // PLE...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
61669d527972c13f963d116a41ed0750
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.*; import java.util.*; public class A { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void solve() throws IOException { int t = 1; while (t-- > 0) { ...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
7192905adcfe0e3d51b00ae04f960eb9
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); HashMap<String,Long> data = new HashMap<String,Long>(); for(int i=0;i<n;i++){ int t = scanner.nextInt(); long a = L...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
cd97f64883b1505e34f8cdc3d6b89da1
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.*; import java.util.*; public class c{ static int mod=1000000007; static PrintWriter out = new PrintWriter(System.out); static class pair{ long x,y; pair(long a,long b){ x=a; y=b; ...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
9c60ed0a34cbfa8fc9092c64aa3dc669
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; int[] dx = {0, -1, 0, 1}; int[] dy = {1, 0, -1, 0}; Map<Long, Long> hm = new HashMap<...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
841b2742dda0b17f823e56d4ea90266d
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.util.TreeMap; import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.io.BufferedReader; import java.util.Map; import java.util.Collection; import java.io.OutputStream; import java.util.Collections; import java.io.PrintWriter; import java....
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
0c36845830ad4a224b8bbc167916c9c0
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class LorenzoVonMatterhorn { static long ans; ...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
81fa9d5a543dfa8eb4d28f7937c08b19
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main1 { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (n...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
5e0a56b060c4378c7a6ae9fdb4b7cd27
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.Locale; import java.util.StringTokenizer; public class A implements Runnable { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private BufferedReader in; private PrintWriter out; private StringTokeniz...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
50a36ae48ac1a64d9091d32259241dc2
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class A extends cf { public static void main(String[] args) {A a=new A();} public void run(InputReader in, PrintWriter out) { int q=in.nextInt(),c; long t,cur,tot; String v,u,e; Map<String,Long>...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
3237b562ac8c417fcacc39b3530fc577
train_002.jsonl
1468514100
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; // this is not good for reading double values. public class Problem696A { static long m =...
Java
["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"]
1 second
["94\n0\n32"]
NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals...
Java 8
standard input
[ "data structures", "implementation", "trees", "brute force" ]
12814033bec4956e7561767a6778d77e
The first line of input contains a single integer q (1 ≤ q ≤ 1 000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ...
1,500
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
standard output
PASSED
fd5e3724ebe37cbff447602fb5b5efd1
train_002.jsonl
1477922700
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monster be...
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.Random; import java.util.StringTokenizer; public class Solution{ static PrintWriter out = new PrintWriter(System.out); static int curn; static int[] a;...
Java
["6\n1 2 2 2 1 2\n2\n5 5", "5\n1 2 3 4 5\n1\n15", "5\n1 1 1 3 3\n3\n2 1 6"]
1 second
["YES\n2 L\n1 R\n4 L\n3 L", "YES\n5 L\n4 L\n3 L\n2 L", "NO"]
NoteIn the first example, initially there were n = 6 monsters, their weights are [1, 2, 2, 2, 1, 2] (in order of queue from the first monster to the last monster). The final queue should be [5, 5]. The following sequence of eatings leads to the final queue: the second monster eats the monster to the left (i.e. the fir...
Java 11
standard input
[ "dp", "constructive algorithms", "two pointers", "greedy" ]
a37f805292e68bc0ad4555fa32d180ef
The first line contains single integer n (1 ≤ n ≤ 500) — the number of monsters in the initial queue. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial weights of the monsters. The third line contains single integer k (1 ≤ k ≤ n) — the number of monsters in the queue after the joke. The ...
1,800
In case if no actions could lead to the final queue, print "NO" (without quotes) in the only line. Otherwise print "YES" (without quotes) in the first line. In the next n - k lines print actions in the chronological order. In each line print x — the index number of the monster in the current queue which eats and, sepa...
standard output
PASSED
253101efde62529e09c1d65783791a77
train_002.jsonl
1477922700
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monster be...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class d { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));; public static void main(String[] args) throws IOException { // Scanner s = new Scanner...
Java
["6\n1 2 2 2 1 2\n2\n5 5", "5\n1 2 3 4 5\n1\n15", "5\n1 1 1 3 3\n3\n2 1 6"]
1 second
["YES\n2 L\n1 R\n4 L\n3 L", "YES\n5 L\n4 L\n3 L\n2 L", "NO"]
NoteIn the first example, initially there were n = 6 monsters, their weights are [1, 2, 2, 2, 1, 2] (in order of queue from the first monster to the last monster). The final queue should be [5, 5]. The following sequence of eatings leads to the final queue: the second monster eats the monster to the left (i.e. the fir...
Java 11
standard input
[ "dp", "constructive algorithms", "two pointers", "greedy" ]
a37f805292e68bc0ad4555fa32d180ef
The first line contains single integer n (1 ≤ n ≤ 500) — the number of monsters in the initial queue. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial weights of the monsters. The third line contains single integer k (1 ≤ k ≤ n) — the number of monsters in the queue after the joke. The ...
1,800
In case if no actions could lead to the final queue, print "NO" (without quotes) in the only line. Otherwise print "YES" (without quotes) in the first line. In the next n - k lines print actions in the chronological order. In each line print x — the index number of the monster in the current queue which eats and, sepa...
standard output
PASSED
fc4d6e0aa4aa3b4cf9c0af4fdaf4c408
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); ...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
10779a1350c3679cb67521111b15ed55
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.util.*; import java.io.*; public class c { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); boolean[] prime = new boolean[100001]; Arrays.fill(prime, true); for(int i = 2; i<prime.length; i++) { ...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
3caf6949c71948a76454f18d3958e83e
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.util.*; public class CF510E_FoxAndDinner { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int size = (int) (10e4*2+10); boolean[] primes = new boolean[size]; Arrays.fill(primes, true); for(int i = 2; i < size; i ++){ if(!primes[i])continue...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
04554dd8d7a854d8588f7fa4fcc463c6
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
// package Div2; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class Sketch { // Dinic algorithm public static final int INF = 100000000; public static final int NMAX = 100000; public static class Edge { public int ne...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
9ff28c4cf86fd11b4476d9e143df2ac8
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
b49c7c33a5179562406478bb4b949cb2
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class CF_510E { public static void main(String[] args) throws IOException { new CF_510E().solve(); } int[] findPath(int[][]resid, int src, int sink){ int[] from=new int[resid.length]; Arrays.fill(from, -1)...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
d672b833beec1d05cbfc5ca08eb4c100
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; /* 4 3 4 8 9 5 2 2 2 2 2 12 2 3 4 5 6 7 8 9 10 11 12 13 24 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 */ public class e { public static void main(String[] args) { Scanner in = n...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
5126b8a34789e28a3a72df886f04bb7e
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.io.*; import java.util.*; public class cf290E { static boolean[] primes = new boolean[20010]; public static void main(String[] args) throws Exception { // BufferedReader in = new BufferedReader(new FileReader("cf290E.in")); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
0456c5c55b18e4370c314d8923b938a2
train_002.jsonl
1422894600
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table. Each table has at least 3 foxes sitting around it. The sum of ages...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void main(String[] args) throws Exception { new E().solve(); } void solve() throws IOException { FastScanner in = new FastScanner(System.in); boolean[] isPrime = new boolean[112345]; Arrays.fill(isPrime,...
Java
["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]
2 seconds
["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24"]
NoteIn example 1, they can sit around one table, their ages are: 3-8-9-4, adjacent sums are: 11, 17, 13 and 7, all those integers are primes.In example 2, it is not possible: the sum of 2+2 = 4 is not a prime number.
Java 7
standard input
[ "flows" ]
5a57929198fcc0836a5c308c807434cc
The first line contains single integer n (3 ≤ n ≤ 200): the number of foxes in this party. The second line contains n integers ai (2 ≤ ai ≤ 104).
2,300
If it is impossible to do this, output "Impossible". Otherwise, in the first line output an integer m (): the number of tables. Then output m lines, each line should start with an integer k -=– the number of foxes around that table, and then k numbers — indices of fox sitting around that table in clockwise order. If th...
standard output
PASSED
9b7737678aa6548ce44baa3e9a70e882
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class Banana { public static boolean can(int []a,int n,int len) { int needed=0; for(int x:a) needed+=(...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
85fcaeb3a6d55876aaed481a16ea7477
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class Banana { public static boolean can(int []a,int n,int len) { int needed=0; for(int x:a) { if(x!=...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
0fe70a3aff26c33e47e06cfea87d83a2
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static void solve(InputReader in, OutputWriter out) { String s = in.next(); int n = in.nextInt(); Map<Character, Integer> letters = new HashMap<>(); int maxCnt = 0; for (int i = 0; i < s.length(); i++) { ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
49a577b105763eddb94f77415bdafa75
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.awt.Point; public class Newbie { static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { solver s = ne...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
f15ff8f9e9256515c4b3c04cc703173c
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.awt.Point; public class Newbie { static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { solver s = ne...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
e45aa9698b539690696856dc03f55c52
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; public class test { static int getLen(HashMap<Character, Integer> map, int k){ int n = 0; for (Map.Entry<Character, Integer> elem : map.entrySet()){ n += Math.ceil(((double) elem.getValue()) / k); } return n; } public static...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
76c484cfbf95d282c39611e9c90debdc
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; public class test { static int getLen(HashMap<Character, Integer> map, int k){ int n = 0; for (Map.Entry<Character, Integer> elem : map.entrySet()){ n += Math.ceil(((double) elem.getValue()) / k); } return n; } public static...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
b8fd1e6b1b0fd7b22657785ef0a574ab
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
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
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
183b2bedbb33c171678c1a2285969770
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CF335A { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc = new Scanner(Syste...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
36b1bb6d39257e44d0a5024ee5d3c061
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
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.StringTokenizer; public class C { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); PrintWriter ou...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
4fbefe9bc18adca3510344ce3f9b9cb9
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.List; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.ArrayList; import java.util.NoSuchElemen...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
f7f6de873b6c1111ce01a0082a8b01be
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String []args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); solve(in, out); in.close(); o...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
8f403b0d74f3e08d23a366bf523228ce
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; public class CF335A { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { char []input = sc.nextLine().toCharArray(); int n = Integer.parseInt(sc.nextLine()); int []inputCharFreq = new int[26]; int uniqueChars = 0; f...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
375e938c0a8ce3b02ca52291fdd6e209
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; public class Main implements Runnable { int INF = (int) 1e9; List<Integer> edges[]; int anc[][]; int ts[], te[]; int t; private void ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
193ec2152bc0b52b5c6fa287d22e4dc8
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; public class Main implements Runnable { int INF = (int) 1e9; List<Integer> edges[]; int anc[][]; int ts[], te[]; int t; private void ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
beb9e5f2b2996433057adb4db5c0b64d
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; public class Main implements Runnable { int INF = (int) 1e9; List<Integer> edges[]; int anc[][]; int ts[], te[]; int t; private void ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
2f8ad6c2c3e5592ea359ab31b17eb889
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Banana implements Closeable { private InputReader in = new InputReader(System.in); priv...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
cf7f8337c0e897292e3ebba25c985d03
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public st...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
49a5861075c30d413643481c51ffff95
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.Scanner; public class Banana { static String sol; static int n; private static int [] freq = new int[26]; public static void main(String[] args) { Scanner fin = new Scanner(System.in); String s = fin.nextLine(); n = fin.nextInt(); int i; ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
a78e9ef75ce6dd81200e271c297903be
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.util.function.*; public class Main { final static String fileName = ""; final static boolean useFiles = false; public static void main(String[] args) throws FileNotFoundException { InputStream inputStream; OutputStream o...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
2fd3e50003e5534183a8128dd4c79c6d
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.io.BufferedReader; public class Main{ static int[][] grid; public static void main(String[...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
abcefd0f7d86904227b25279ebc61834
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); t...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
edbd7bac3718a8eda536e66c4a34c74e
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; import javax.sound.midi.Synthesizer; public class Problem5 { static ArrayList<Integer> primes; static void sieve(int N) { boolean[] isComposite = new boolean[N]; primes = new ArrayList<Integer>(N / 10); for(int i = 2; i < N; ++i) if(!isComposite[i]) { primes.a...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
71281d0a7045822cdfb774444b7256d2
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; import javax.sound.midi.Synthesizer; public class Problem5 { static ArrayList<Integer> primes; static void sieve(int N) { boolean[] isComposite = new boolean[N]; primes = new ArrayList<Integer>(N / 10); for(int i = 2; i < N; ++i) if(!isComposite[i]) { prime...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
7b2717cefc3e91e8563caaf8ab01a3d1
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Banana { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); int n = Integer...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
90821ea76c1684990ac640a7ecb4a237
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.awt.Point; 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.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Abood3A { p...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
e62c6bb02dd84b8b48f2315a287897e9
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.awt.Point; 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.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Abood3A { p...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 8
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
46b94cc0bf02e35985e5d5b82c6bb9ee
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; public class P335A { private static class Letter implements Comparable<Letter> { char c; int total; int occu; public Letter(char c, int total, int occu) { this.c = c; this.total = total; this.occu = occu; ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
01a18ff4628059da9ed39f1c1e1b41b6
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Banan { public static class Letter implements Comparable<Letter>{ public Letter(char c, int count){ this.letter = c; this.stickCount = 1; this.str�ount = count; } char letter; ...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
5f459eb962cb835376c128f8a903a6b0
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; import java.io.*; public class CodeForces { public static void main(String[] args) throws Exception{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String s = in.readLine(); int n = Integer.parseInt(in.readLine()); numStamp(s, n); } public static void numStam...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
2b0537bb5beecfc6b6ca832cb94d8b16
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamReade...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
2de2594117e6d228d0ea27d9ad57980c
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; int[] cnt; int N; public void solve() throws IOException { cnt = ne...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
b82079e7cfbcd4ddd56c6a8c7d7c29b2
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; public class maximus { public static void main(String [] args){ Scanner in=new Scanner(System.in); String str=in.next(); int n=in.nextInt(); int array[]=new int[26]; for(int i=0;i<str.length();i++)array[str.charAt(i)-97]++; int high=1001; int low=0; int cnt=0; for(int i=0;...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
b05ac8e9b8aa012e55cca0b48eb03fa0
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.util.*; import java.io.*; public class a { static long mod = 1000000009; static ArrayList<Integer>[] g; public static void main(String[] args) throws IOException { //Scanner input = new Scanner(new File("input.txt")); //PrintWriter out = new PrintWriter(new File("output.txt")); input.init(...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
202e75b60a21dfdbd466ffbf701851b7
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class A implements Runnable { private void solve() throws IOException { String s = nextToken(); int n = nextInt(); i...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
601465c085d487d60fecf0cd164f3383
train_002.jsonl
1375549200
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static class Pair implements Comparable<Pair> { public char c; public int f; public Pair(char c, int f) { this.c = c; this.f = f; } public int compareTo(Pair pair) { if (this...
Java
["banana\n4", "banana\n3", "banana\n2"]
2 seconds
["2\nbaan", "3\nnab", "-1"]
NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".
Java 6
standard input
[ "constructive algorithms", "binary search", "greedy" ]
f16f00edbc0c2e984caa04f71ae0324e
The first line contains string s (1 ≤ |s| ≤ 1000), consisting of lowercase English characters only. The second line contains an integer n (1 ≤ n ≤ 1000).
1,400
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print ...
standard output
PASSED
de8eb990885e5c8b51c783c935850c32
train_002.jsonl
1312390800
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no desire whatsoever to l...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // SHIVAM GUPTA : //NSIT //decoder_1671 // STOP NOT TILL IT IS DONE OR U DIE . // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = ...
Java
["aaaaa\n4", "abacaba\n4", "abcdefgh\n10"]
2 seconds
["1\naaaaa", "1\naaaa", "0"]
NoteIn the first sample the string consists of five identical letters but you are only allowed to delete 4 of them so that there was at least one letter left. Thus, the right answer is 1 and any string consisting of characters "a" from 1 to 5 in length.In the second sample you are allowed to delete 4 characters. You ca...
Java 11
standard input
[ "greedy" ]
f023111561605b3e44ca85cb43b4aa00
The first input data line contains a string whose length is equal to n (1 ≤ n ≤ 105). The string consists of lowercase Latin letters. The second line contains the number k (0 ≤ k ≤ 105).
1,200
Print on the first line the only number m — the least possible number of different characters that could remain in the given string after it loses no more than k characters. Print on the second line the string that Gerald can get after some characters are lost. The string should have exactly m distinct characters. The ...
standard output
PASSED
7b0d8c9e235fba55d05a26256a01613a
train_002.jsonl
1312390800
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no desire whatsoever to l...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String str = sc.next(); int k = sc.nextInt(); // Get Frequency Of Chars int counter[] = new int[150]; for(int i =...
Java
["aaaaa\n4", "abacaba\n4", "abcdefgh\n10"]
2 seconds
["1\naaaaa", "1\naaaa", "0"]
NoteIn the first sample the string consists of five identical letters but you are only allowed to delete 4 of them so that there was at least one letter left. Thus, the right answer is 1 and any string consisting of characters "a" from 1 to 5 in length.In the second sample you are allowed to delete 4 characters. You ca...
Java 11
standard input
[ "greedy" ]
f023111561605b3e44ca85cb43b4aa00
The first input data line contains a string whose length is equal to n (1 ≤ n ≤ 105). The string consists of lowercase Latin letters. The second line contains the number k (0 ≤ k ≤ 105).
1,200
Print on the first line the only number m — the least possible number of different characters that could remain in the given string after it loses no more than k characters. Print on the second line the string that Gerald can get after some characters are lost. The string should have exactly m distinct characters. The ...
standard output
PASSED
5a0c78382157f6701f1ae49eba4a8d5c
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.StringTokenizer; import java.util.Iterator; public class acm_practice { public static void main(String[] args) throws IOExce...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
1b671e616413b355b37b8f7026b1693b
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.*; import java.util.*; public class TestClass{ public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer....
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
0aa3601ab3e0c9cb0d299e5853237128
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.util.Collections; import java.io.InputStream...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
c2909d743412441d9867a4bcadd13725
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.HashMap; import java.util.Scanner; import java.util.TreeMap; import java.util.TreeSet; public class transmigration { // reading 53 01 // thinking 01 03 // coding 03 07 // debuging 07 09 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
1d8d1181196703ced1019b2e073576d6
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.Scanner; import java.util.TreeMap; import java.util.Map.Entry; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); TreeMap<String, Integer> skills = new TreeMap<>(); int n = sc.nextInt(), m = sc.nextInt(), k = (int)Math.round(sc.nextDouble() * 100);...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
dd49bd597e7ab21114fb36eef3a5fbfa
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; public class E { public static void main(String[] ar...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
0498cee38be53bd0723ede81a77d0640
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
//package CodeForces; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Scanner; public class Transmigration { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int n=s.n...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
58b4113b2ddbb3133c42b379ed4d99f4
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
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.Collections; import java.util.HashSet; import java.util.StringTokenizer; public class Transmigration { static double eps=1e-9; public static void main(...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
49974fdc1840c8405072f5448b576bdb
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class transmigration { public static void main(String[] args) { Scanner s = new Scanner(System.in); int skills = s.nextInt(); int skillst = s.nextInt(); double d = s.nextDouble(); TreeMap<String, Integer> hm = new TreeMap<Strin...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
5f3f4b59c64358dcd40c5b58cf2d3d9c
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Str...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
b81de8a5839e5ad9da746bcbdd3355fb
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.TreeMap; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Mouna Cheikhna */ pub...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
78149bcbbb07124295044e1767cb77d8
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.*; import java.io.*; public class transmigration { public static String toString(skill o){ return o.name + " " + o.exp; } static class skill implements Comparable<skill>{ String name; int exp; public skill(String name, int exp){ this.name = name; this.e...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
b520c5d6877b3475d3b9be3b2f6cd846
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.*; import java.math.BigDecimal; public class HelloWorld{ static class pair{ String a; int b; } public static void main(String []args){ Scanner s=new Scanner(System.in); int n=s.nextInt(); int m=s.nextInt(); double k=s.nextDouble(); pair[] ...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
deb4c3e03b40ade98c6a505ebffd89b3
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.TreeMap; public class Transmigration { public static void main(String[] args) throws IOException { BufferedReader axa = new BufferedReader(new InputStreamReader(System.in)); String [] te = axa.readLine().split(" "); int have = Integer.parseInt(te[0...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
c22217d1736ab4fe84f652a2d9d86507
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException{ Scanner sc=new Scanner(System.in); StringBuilder sb=new StringBuilder(); PrintWriter out= new PrintWriter(System.out); int n=sc.nextInt(); int m=sc.nextInt(); double k=sc.nextDouble(); Tre...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
b2dcc0593b6fdff2d1c3d67c284173b8
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class ChatOrder { public static void main(String[] args) throws IOException { Scanner sc= new Scanne...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
bd6cb2378c34c47ec604ca2001efa0f5
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.*; import java.util.*; public class A105 { static class Skill implements Comparable<Skill> { String s ; int e; public Skill(String s , int e) { this.s=s; this.e=e; } public int compareTo(Skill h) { return s.compareTo(h.s); } public String toString() { return s+" "+e; ...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
046294b0fad57681fa2f1b9ecef1aff6
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
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.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.Set; import java.u...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
0631de5c4ad0ecd3ef3123f054392728
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeMap; public class transmigration { static class Scanner { StringTokenizer st; ...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
bbcaa72a410043da96b0b786c3084b06
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class Main { static Scanner sc = new Scanner(Syste...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
ef0810365304420e2175a2e22aa39c87
train_002.jsonl
1313247600
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class Main { static Scanner sc = new Scanner(Syste...
Java
["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"]
2 seconds
["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"]
null
Java 8
standard input
[ "implementation" ]
7da1a5c4c76540e1c7dc06e4c908c8b4
The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p...
1,700
Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
standard output
PASSED
1f76e08eee45b5e84d490af8d1f1462c
train_002.jsonl
1567175700
Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $$$n$$$ last days: $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the price of berPhone on the day $$$i$$$.Polycarp considers the price on the day $$$i$$$ to be bad if later (that is, a day with a greater number) berPhone was sold at a...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.PrintStream; import java.util.Scanner; import java.util.SortedSet; import java.util.TreeSet; import static java.lang.Integer.max; public class Main implements Runnable, AutoCloseable { Scanner in = new Scanner(new BufferedInpu...
Java
["5\n6\n3 9 4 6 7 5\n1\n1000000\n2\n2 1\n10\n31 41 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5"]
1 second
["3\n0\n1\n8\n2"]
null
Java 8
standard input
[ "data structures", "implementation" ]
09faf19627d2ff00c3821d4bc2644b63
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of sets of input data in the test. Input data sets must be processed independently, one after another. Each input data set consists of two lines. The first line contains an integer $$$n$$$ ($$$1 \le n \le 150000$$$) — the number of days. ...
1,100
Print $$$t$$$ integers, the $$$j$$$-th of which should be equal to the number of days with a bad price in the $$$j$$$-th input data set.
standard output
PASSED
6524a7f13f9f6ae5104c41e8392ad61a
train_002.jsonl
1567175700
Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $$$n$$$ last days: $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the price of berPhone on the day $$$i$$$.Polycarp considers the price on the day $$$i$$$ to be bad if later (that is, a day with a greater number) berPhone was sold at a...
256 megabytes
//import java.util.Arrays; import java.util.Scanner; public class SecondTask { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t =in.nextInt(); for(int i=0;i<t;i++) { int n = in.nextInt(); int[] num = new int[n]; for(in...
Java
["5\n6\n3 9 4 6 7 5\n1\n1000000\n2\n2 1\n10\n31 41 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5"]
1 second
["3\n0\n1\n8\n2"]
null
Java 8
standard input
[ "data structures", "implementation" ]
09faf19627d2ff00c3821d4bc2644b63
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of sets of input data in the test. Input data sets must be processed independently, one after another. Each input data set consists of two lines. The first line contains an integer $$$n$$$ ($$$1 \le n \le 150000$$$) — the number of days. ...
1,100
Print $$$t$$$ integers, the $$$j$$$-th of which should be equal to the number of days with a bad price in the $$$j$$$-th input data set.
standard output
PASSED
90eecfea61fa11d4d0495660129ce2a1
train_002.jsonl
1567175700
Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $$$n$$$ last days: $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the price of berPhone on the day $$$i$$$.Polycarp considers the price on the day $$$i$$$ to be bad if later (that is, a day with a greater number) berPhone was sold at a...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class BadPrices { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Scanner(System.in); int t=0; t=sc.nextInt(); wh...
Java
["5\n6\n3 9 4 6 7 5\n1\n1000000\n2\n2 1\n10\n31 41 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5"]
1 second
["3\n0\n1\n8\n2"]
null
Java 8
standard input
[ "data structures", "implementation" ]
09faf19627d2ff00c3821d4bc2644b63
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of sets of input data in the test. Input data sets must be processed independently, one after another. Each input data set consists of two lines. The first line contains an integer $$$n$$$ ($$$1 \le n \le 150000$$$) — the number of days. ...
1,100
Print $$$t$$$ integers, the $$$j$$$-th of which should be equal to the number of days with a bad price in the $$$j$$$-th input data set.
standard output
PASSED
b70f2e453a24d4fa5464101c93da2514
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.*; import java.math.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; //class Declaration static class pair implement...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
b2d4dc7e07e3ca794955aa045109d4d1
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ long rem = 1000000000L; InputReader sc; boolean singleTest = true; ArrayList<Integer>[] adj; int[] a; int[] b; int[] c; boolean[] visited; long res; public void solve(int test){ int n = nextInt(); a = new int[n+1]; b = new int[n+1]; ...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
dc95185125a97e3ebd2b000429161654
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=998244353L; int[][] dir=new int[][] {{0,1},{1,0},{0...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
1636ac628f2f005202fe517d5aba06a8
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } int[] cnt0; int[] cnt1; int[] c; LinkedList<Integer> adj[]; public void run() throws Exception { FastScanner f = new FastScan...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
b9dd38fd332f37ac686002542becc4b7
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unchecked") public class Problem_E { static final long INF = Long.MAX_VALUE / 2; static List<Integer>[] G; static long[] A, dp; static int[] B, C; public static void dfs(int x, int p) { for (int y : G[x]) { if (y == p) { continue; } A[y] = M...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
62a749b306073521a060e9535894eada
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unchecked") public class Problem_E { static final long INF = Long.MAX_VALUE / 2; static List<Integer>[] G; static long[] A, dp; static int[] B, C, D, E; public static void dfs(int x, int p) { dp[x] = B[x] == C[x] ? 0 : A[x]; for (int y : G[x]) { if ...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
29a8ce146d28e1f3f320d2425ac1733c
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
//package codeforces; import java.io.*; import java.util.*; public class TreeShuffling { int V; static LinkedList <Integer> ar[]; static long arr[]; static int a[]; static int b[]; static long cost=0; public TreeShuffling(int v) { ar=new LinkedList[v]; for(int i=0;i<v;i++) { ar[i]=new LinkedList<>(); ...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
3abff48627cd73ac123f7eb1ce4c6876
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.util.*; public class Main { final static int maxn=(int)2e5+10; static int a[]=new int [maxn]; static int b[]=new int [maxn]; static int c[]=new int [maxn]; static Vector<Integer>vec[]=new Vector[maxn]; static long cost=(int)1e9+10; static int num1[]=new int [maxn]; static int num0[]=new int [maxn]; ...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
92a47388e287060b170930e7db73bbad
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.*; import java.util.*; public class E1 { public static HashMap<Integer, node> map; public static HashMap<node, HashSet<node>> tree; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWrit...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
e6da0c9cd68c91818bc8c18f246e1c36
train_002.jsonl
1590935700
Ashish has a tree consisting of $$$n$$$ nodes numbered $$$1$$$ to $$$n$$$ rooted at node $$$1$$$. The $$$i$$$-th node in the tree has a cost $$$a_i$$$, and binary digit $$$b_i$$$ is written in it. He wants to have binary digit $$$c_i$$$ written in the $$$i$$$-th node in the end.To achieve this, he can perform the follo...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.stream.IntStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.Collection; import java.util.InputMismatchException; import java.util.HashMap; import java.io.I...
Java
["5\n1 0 1\n20 1 0\n300 0 1\n4000 0 0\n50000 1 0\n1 2\n2 3\n2 4\n1 5", "5\n10000 0 1\n2000 1 0\n300 0 1\n40 0 0\n1 1 0\n1 2\n2 3\n2 4\n1 5", "2\n109 0 1\n205 0 1\n1 2"]
2 seconds
["4", "24000", "-1"]
NoteThe tree corresponding to samples $$$1$$$ and $$$2$$$ are: In sample $$$1$$$, we can choose node $$$1$$$ and $$$k = 4$$$ for a cost of $$$4 \cdot 1$$$ = $$$4$$$ and select nodes $$${1, 2, 3, 5}$$$, shuffle their digits and get the desired digits in every node.In sample $$$2$$$, we can choose node $$$1$$$ and $$$k =...
Java 8
standard input
[ "dp", "dfs and similar", "greedy", "trees" ]
4dce15ff1446b5af2c5b49ee2d30bbb8
First line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ denoting the number of nodes in the tree. $$$i$$$-th line of the next $$$n$$$ lines contains 3 space-separated integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ $$$(1 \leq a_i \leq 10^9, 0 \leq b_i, c_i \leq 1)$$$  — the cost of the $$$i$$$-th node, i...
2,000
Print the minimum total cost to make every node reach its target digit, and $$$-1$$$ if it is impossible.
standard output
PASSED
678bf7445e3ccfa23e287a7cb5dbf73e
train_002.jsonl
1366040100
This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); OutputStream out = new BufferedOutputStream ( System.out ); //try { int n = sc.nex...
Java
["4 3\n1 2\n2 3\n3 4", "4 4\n1 2\n2 3\n3 4\n4 1", "4 3\n1 2\n1 3\n1 4", "4 4\n1 2\n2 3\n3 1\n1 4"]
2 seconds
["bus topology", "ring topology", "star topology", "unknown topology"]
null
Java 8
standard input
[ "implementation", "graphs" ]
7bb088ce5e4e2101221c706ff87841e4
The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that ...
1,200
In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topolo...
standard output
PASSED
d9e883ef198916a0da5d1cb8fb45c266
train_002.jsonl
1366040100
This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are...
256 megabytes
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.util.Collections; i...
Java
["4 3\n1 2\n2 3\n3 4", "4 4\n1 2\n2 3\n3 4\n4 1", "4 3\n1 2\n1 3\n1 4", "4 4\n1 2\n2 3\n3 1\n1 4"]
2 seconds
["bus topology", "ring topology", "star topology", "unknown topology"]
null
Java 8
standard input
[ "implementation", "graphs" ]
7bb088ce5e4e2101221c706ff87841e4
The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that ...
1,200
In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topolo...
standard output