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
f12e5c183cf84f96db3a5e91e9c1ea09
train_000.jsonl
1576386300
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
256 megabytes
import java.util.Scanner; public class Azamon_Web_Services { public static void main(String[] args) { Scanner in = new Scanner(System.in); int tests = in.nextInt(); for (int i = 0; i< tests; i++) { String yours = in.next(); String competitor = in.next(); int k; int current; //index of firstest lett...
Java
["3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA"]
2 seconds
["AMAZON\n---\nAPPLE"]
NoteIn the first test case, it is possible to swap the second and the fourth letters of the string and the resulting string "AMAZON" is lexicographically smaller than "APPLE".It is impossible to improve the product's name in the second test case and satisfy all conditions.In the third test case, it is possible not to s...
Java 11
standard input
[ "greedy" ]
88743b7acb4a95dc0d5bb2e073714c49
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 1500$$$) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing two space-separated strings $$$s$$$ and $$$c$$$ ($$$2 \le |s| \le 5000, 1 \le |c| \le 5000$$$)....
1,600
For each test case, output a single line containing a single string, which is either the new name which is obtained after swapping no more than one pair of characters that is strictly lexicographically smaller than $$$c$$$. In case there are many possible such strings, you can output any of them; three dashes (the s...
standard output
PASSED
45e2500c21d0c477aa7d32f72ebec4e4
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
3a7adb1541f39a5b927e9b75bbb146fb
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static long ceil(long a, long b) { return (a+b-1)/b; } public static void main(String[] args) throws IOException{ int t = sc.nextInt(); while (t-->0){ long x = sc.nextInt()-1; long y = sc.nextInt(); long torch = sc.nextLong(); long needed ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
41e7091907cf183ae20d4d5ee8f82749
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class App { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long t = sc.nextInt(); for (long c = 1; c <= t; c++) { long count = 0; long x = sc.nextInt(); long y = sc.nextInt(); lon...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
f06063ad3cdf6915f1f868f248fabbae
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.net.Inet4Address; import java.nio.channels.InterruptedByTimeoutException; import java.util.*; import java.io.*; import java.text.*; import java.math.*; public class Main { public static FastIO file = new FastIO(); private static void solve() { int amount = nextInt(); long coalTrade...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
c5e10a5d6b37b9a685a3a51187b43a80
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; public class solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { long x=sc.nextLong(); long y=sc.nextLong(); long k=sc.nextLong(); long s=k*(y+1); long a; s=s-1; if(s%(x-1)==0) { a=s/(x-1...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
09b227a9c667d6b074716091b2647ef9
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class CodeForces { private final static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in))); private static long solve(int x, int y, int k) { //get k coals long sticksNeede...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
4ff6b4b2ee1d798a87d60d17f72a4b43
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
//package hiougyf; import java.io.*; import java.util.*; import java.util.Map.Entry; public class Solution { public static void main(String[] args){ Scanner sc =new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long x=sc.nextLong(),y=sc.nextLong(),k=sc.nextLong(); long v= (k*y+k-1); long p=...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
c94ee48c4b27c2e716b10b2bc5acc6a9
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
//package hiougyf; import java.io.*; import java.util.*; import java.util.Map.Entry; public class Solution { public static void main(String[] args){ Scanner sc =new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long x=sc.nextLong(),y=sc.nextLong(),k=sc.nextLong(); long v= (k*y+k-1); long an...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
668e8ce1add4529ab8d3767de66537b2
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; import java.io.*; public class A { private static final int mod =(int)1e9+7; public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { lo...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
4d9cea19db5d1f2db22c39acedc31891
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Test { public static void main (String[] args) throws java.lang.Exception { Scanner s=new Scanner(System.in); int test=s.nextInt(); for(int i=0;i<test;i++) { long x=s.nextInt(); long y=s.nextInt(); ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
5e2bdd0538cd36ea5af7e57a39526d12
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); while(t--...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
6b78e374d6416c0ca951e027a3a86d52
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T-- > 0) { int n = sc.nextInt(); int y = sc.nextInt(); int k = sc.nextInt(); long tS = (long)k*(1+y); long count = (tS...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
6be297619c577305b6730bdfdf27a51d
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *****************************************************...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
9ebcc52ac8dee103364624309a8564b1
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.*; import java.util.*; public class noob { InputReader in; final long mod=1000000007; StringBuilder sb; public static void main(String[] args) throws java.lang.Exception { new noob().run(); } void run() throws Exception { in=new InputReader(System.in); sb =...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
030b065149f2725f4f4dc9d4cb8be14b
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class BuyingTorches { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { //Helloworld long n = sc.nextLong(); long c = sc.nextLong(); long k =...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
883441bf490bf4ad561dfae2b3ca3476
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int t = sc.nextInt(); while (t-- > 0) { long x=sc.nextLong...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
7e0c049ba06f81e545a65b3e0acc04a3
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.text.ParseException; import java.util.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static StringBuilder sb = new StringBuilder("");...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
3f83ddafea908a92bf14826f0a14df9c
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.BufferedReader; import java.util.Scanner; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterat...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
bc027ee22622c7bcb6d325fef64ea40e
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class BuyingTorches { //1418A: 购买火炬 private long exSticks; //在一次交易中1单位木棍能够兑换的木棍数量 private long exCoals; //在一次交易中兑换1单位煤需要的木棍数量 private long torchesNumber; //需要合成的火炬数量 private long tradeNumber; //交易发生的次数 private BuyingTorches() { } public BuyingTorches(long exSticks,long...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
3fe8aa1e0631b8e4e45ecf8fc4448204
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class q1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long t=sc.nextInt(); for(long c=1;c<=t;c++){ long count=0; long x= sc.nextInt(); long y=sc.nextInt(); long k=sc.nextInt();...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
59c8b65b5fac9d50a7834dea9aad34db
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
/* package codechef; // don't place package name! */ 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 Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); in...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
8461de33be8e402ad15908f6e1eaf943
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for (int i =0; i<t; i++){ long n1 = scn.nextLong(); long n2 = scn.nextLong(); long n3 = scn.nextLong(); ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
86a0d522330a000d3b8771d58810ceaa
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; public class C1418A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); for(int i = 0 ; i < t ; i++) { long x = sc.nextLong(); long y = sc.nextLong(); long k = sc.nextLong(); long gain = x-1; long neededSticks = k*y-1; long ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
c70cad23c447cf4f212a105c79cc9d27
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.util.*; public class C1418A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); for(int i = 0 ; i < t ; i++) { long x = sc.nextLong(); long y = sc.nextLong(); long k = sc.nextLong(); long gain = x-1; long neededSticks = k*y-1; long ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
2f3a39bf9dc7e52c4a4ccc3a85b137ff
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; public class Solve8 { ...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
c9fb89a55ec8041c27d6ee035cfaa3e6
train_000.jsonl
1600094100
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $$$k$$$ torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handsome wandering trader who has two trade offers: exchange $$$1$$$ stick for $$$x$$$ sticks (you lose $$$1$$$ stick...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); Case[] cases=new Case[n]; for(int i=0;i<n;i++){ Case c=new Case(); cases[i]=c; cases[i].x=scan.nextLong(); cases[i]...
Java
["5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000"]
1 second
["14\n33\n25\n2000000003\n1000000001999999999"]
null
Java 11
standard input
[ "math" ]
28610d192329c78580db354f8dfc4094
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$ and $$$k$$$ ($$$2 \le x \le 10^9$$$; $$$1 \le y, k \le 10^9$$$) — the number of sticks you can buy...
1,000
For each test case, print the answer: the minimum number of trades you need to craft at least $$$k$$$ torches. The answer always exists under the given constraints.
standard output
PASSED
7dc8e6db88e87ac93e90c6d7a13e1a25
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.io.*; import java.util.*; public class Solution{ public static void main(String arg[])throws IOException { BufferedReader io =new BufferedReader(new InputStreamReader(System.in)); String[] input1 = io.readLine().trim().split(" "); int n = Integer.parseInt(input1[0]); ...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
d3fde4d3d4bb4798b3a880ed786f97ed
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.*; public class Solution { private static boolean isSorted(int[] arr) { for (int i = 0; i< arr.length - 1; i++) { if (arr[i] > arr[i+1]) return false; } return true; } private static void reverse(int[] arr, int from, int to) { int i, t; ...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
41e455be1d92aa1cccfeb9339f0c0930
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.*; public class cf311div2B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int w=sc.nextInt(); int arr[]=new int[2*n]; for(int i=0;i<2*n;i++) arr[i]=sc.nextInt(); Arrays.sort(arr); int min1=arr[2*n-1]; int min2=arr[2*n-1]; for(int i=0;i<=n-1;i++) {if(ar...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
5b7529e867c47f4adb4966e01d75d681
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputS...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
8743bab11426d38a0a336c75e4593b37
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { int n, w; List<Integer> as = new ArrayList<>(); Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); ...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
1d8bced5feb17a53afc93b5a7ef83308
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
/* ID: davidzh8 PROG: subset LANG: JAVA */ import java.io.*; import java.util.*; import java.lang.*; public class pashatea { //Start Stub static long startTime = System.nanoTime(); //Globals Go Here //Globals End public static void main(String[] args) throws IOException { boolean debug =...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
c03849b8d0a9cbc45360c4c73acfbba2
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.*; public class HelloWorld { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { String[] data = scanner.nextLine().split(" "); String[] arr = scanner.nextLine().split(" "); int n = Integer.parseInt(data[0]); ...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
ccaf010057a011820531e6a79206f313
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.*; public class Lecture3_Pasha_and_Tea { private static int[] A; private static int n; private static double chk(double lim) { if (Double.compare(lim, A[0]) > 0 || Double.compare(lim * 2, A[n]) > 0) return 0; return (lim * n * 3); } public static void ...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
c67ef8b7b127b2a6df2514ec378fc627
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.util.*; public class Lecture03_Pasha_and_Tea { private static int[] A; private static int n; public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); int w = in.nextInt(); A = new int[2*n]; for(int i = 0; i < 2...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
af1bf04af650440aa13806e6a1aeeaeb
train_000.jsonl
1435676400
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n g...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class PairComparator implements Comparator<Pair> { @Override public int compare(Pair x, Pair y) { if (x.val < y.val) return -1; if (x.val > y.val) return 1; if (x.val == y.val) { if (x.ind < y.ind) return -1; if (x.ind...
Java
["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"]
1 second
["3", "18", "4.5"]
NotePasha also has candies that he is going to give to girls but that is another task...
Java 11
standard input
[ "constructive algorithms", "implementation", "sortings", "math" ]
b2031a328d72b464f965b4789fd35b93
The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, ...
1,500
Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.
standard output
PASSED
17edbe8109ce43a5cbc0b1bba2d0c694
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; // press Ctrl+Shift+L for all shortcut key (Eclipse only !) public class Solution { static MyScanner sc; static PrintWriter pw; public static void main(String[] args) { sc=new MyScanner(); pw=new PrintWriter(System.out); int i; String inp=sc.nextLine(); int lps[]=new ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
49dd7896f326803ea724c6cacbaca1f5
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
////package CodeForce; import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Z1 { static int[] A; static int[] S; static long[] sum; public static int mod=1000000007; static int[][] dp; static boolean[][] isPalin; static int max1=5000...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
883718802577b1896b2c82eb49865847
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String s = br.readLine(); in...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
5002c28174f3f8907402857e21c9c51d
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class D432 { public static int mod = 1000000007; public static long INF = (1L << 60); static FastS...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
a67eaceb83528f7a7156b59b25393f96
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.sql.Array; import java.util.*; import java.util.stream.Stream; public class AtCoder implements Runnable { static final int MOD = (int) 1e9 + 7; static final Reader in = new Read...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
a7bea952ff49b1607fd6c7349df503ed
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.sql.Array; import java.util.*; import java.util.stream.Stream; public class AtCoder implements Runnable { static final int MOD = (int) 1e9 + 7; static final Reader in = new Read...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
6e2332a0f77ebbb6e699ed09d09cd3e1
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import static java.lang.Math.* ; import static java.util.Arrays.* ; import java.util.*; import java.io.*; public class Main { TreeMap<Character , Integer> [] next ; int [] link , len , cnt ; int idx , last ; void addLetter(char c) { int curr = ++idx, p = last; len[curr] = len[p] + 1;...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
2af47f1a9ea64ebf8acb626377942b9b
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.* ; import java.util.*; import java.io.*; public class B { int [] ans ; void KMP (char [] s) { int n = s.length; int [] pi = new int [n + 1] ; ans = new int [n + 1] ; for(int i = 1 , j = 0 ; i < n ; i++) ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
e64ee4748454b9f4230569caa679244a
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.io.IOException; import java.lang.Thread.State; import java.util.*; //import javafx.util.Pair; //import java.util.concurrent.LinkedBlockingDeque; public class Codeforces { public static long mod = (long)Math.pow(10,9)+7 ; public static double epsilon=0...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
1d513cf5cd50eb7e980e46689beae478
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
02b4cb296ef20b63adf8215da6bff2a3
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; import java.util.Arrays; import java.util.Stack; public class D432 { static class Scanner { BufferedReader br; S...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
933546670afc286037dfadf24e1b9954
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; public class temp4 { static class FastReader { BufferedReader br; StringTokenizer st; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
4afff863bded2a54996c25f37d1cc6a9
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.io.*; import java.util.HashMap; import java.util.Map; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); char c[]=br.readLine().toCharArray(); int...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
b88a77403290be4103bd6d0f39150724
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; /* * Heart beats fast * Colors and promises * How to be brave * How can I love when I am afraid to fall... */ //read the question correctly (is y a vowel? what are the exact constraints?) //look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) public class Main...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
6d7eca5f9f40013985874ee1d77d72cc
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import ja...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
97bb5e55e48e4f3a0b09cf3f197780f5
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; 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.Collections; import java.util.HashMa...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
6b0622710df261fe49e5afa2b3163cca
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.image.AreaAveragingScaleFilter; import static java.lang.Math.*; import java.lang.*; public class Main { static FastScanner in; static PrintWriter out; public static void main(String[] args) throws FileNotFoundException { ru...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
42722d078002caf8445d3bd0b65aec63
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.image.AreaAveragingScaleFilter; import static java.lang.Math.*; import java.lang.*; public class Main { static FastScanner in; static PrintWriter out; public static void main(String[] args) throws FileNotFoundException { ru...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
6b1aca60180365391394ed293436c13d
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
c3d4dbd5b65015bcddf0037fb3565fae
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
//package String; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; public class prefixAndSuffix { public static void main(String args[]) { Scanner in = new Scanner(System.in); String text = in.next(); in.close(); int size = text.length(); int[] lps = new int[size]; compu...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
2dcb8347a2e08d40e4dd36b16f54b77e
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
//package String; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; public class prefixAndSuffix { public static void main(String args[]) { Scanner in = new Scanner(System.in); String text = in.next(); in.close(); int size = text.length(); int[] lps = new int[size]; compu...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
2b0e58c3cb3f6e4d01ad22091e4ad533
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc = new Scanner(); PrintWriter out = new PrintWri...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
23d1f545bca5699fdfd0c93fc993eda0
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Vector; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; im...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
a770fc517bc7a3d5269a4d5f5717d45a
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.BufferedOutputStream; import java.util.StringTok...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
ce1e75d7ac97cb5777c40139c45c956f
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.TreeSet; public class _432D { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
ee2843abb90cba75c336b77b0ec5ad90
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { static List<Integer> [] g; static List<...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
39b18c17d86a7466da0aab5978824b36
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { new Thread(null, new Runnable() { public void run() { solve(); } }, "1", 1 ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
fc2e53436f93abe5e193fa0240c88034
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); char[] s = sc.ne...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
a3144bd1ab3ac7e35f5116b19e7a6e45
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * @author Don Li */ public class PrefixesSuffixes { void solve() { char[] s = in.nextToken().to...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
c06c42b4bacea134b642b09165d5d56b
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
/* * * @author Mukesh Singh * */ import java.io.*; import java.util.*; import java.text.DecimalFormat; @SuppressWarnings("unchecked") public class AB { //solve test cases void solve() throws Exception { String st = in.nextToken(); int n = st.length(); int[]Z = new int[n]; compute(Z,st); //for(int a : ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
875a7796b9d055bea373b6ae8683b16a
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
/* * * @author Mukesh Singh * */ import java.io.*; import java.util.*; import java.text.DecimalFormat; @SuppressWarnings("unchecked") public class AB { //solve test cases void solve() throws Exception { String st = in.nextToken(); int n = st.length(); int[]Z = new int[n]; Z[0] = n ; for(int i = 1 , l ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
17578d9b8c4dee8bfd5d9549226ef1e9
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; public class password { static class SuffixAutomaton { int last; ArrayList<Integer> link, length; ArrayList<int []> edges; HashSet<Integer> terminals; public SuffixAutomaton(String s) { link = new...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
41edad6fe06e9826f4592883309dd643
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF432D extends PrintWriter { CF432D() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF432D o = new CF432D(); o.main(); o.flush(); } void main() { byte[] cc = sc.next().getBytes(); ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
712fcb05b26a6cd0fc7851be26b6edd0
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.LinkedList; import java.util.List; import java.util.Scanner; // http://codeforces.com/problemset/problem/432/D public class PrefixesAndSuffixes { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.next(); if (s.length() == ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
6f3dfd11677e7dd2ac8c1c225051d453
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
c8461d3f0b2a5da99ef8c2a0daf8c008
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String ag[]) { Scanner sc=new Scanner(System.in); int i,j,k; String str=sc.next(); int N=str.length(); int Z[]=new int[N]; int left=0; int right=0; for(i=1;i<N;i+...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
f3e65507aeac770f8470e1021aaf41d5
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int[] prefix_function(char[]s) { int n = (int)s.length; int[]pi=new int[n]; for (int i = 1; i < n; i++) { int j = pi[i-1]; while (j > 0 && s[i] != s[j]) j = pi[j-1]; if (s[i] == s[j]) j+...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
9c0c68db03faf44cd31f4a4e3c9766a2
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int[] prefix_function(char[]s) { int n = (int)s.length; int[]pi=new int[n]; for (int i = 1; i < n; i++) { int j = pi[i-1]; while (j > 0 && s[i] != s[j]) j = pi[j-1]; if (s[i] == s[j]) j+...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
0bd440957205cb9a43a3c216559de0ef
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
// http://codeforces.com/problemset/problem/432/D /* Input ABACABA Output 3 1 4 3 2 7 1 Input AAA Output 3 1 3 2 2 3 1 7:35 */ import java.util.*; import java.io.*; public class PrefixesSuffixes { FastScanner in; PrintWriter out; class SuffixTree { final int m = 27; int[] str; int[] parent; int[][] l...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
f3302d1e44617ebc5e3e566c57e968ef
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
// http://codeforces.com/problemset/problem/432/D /* Input ABACABA Output 3 1 4 3 2 7 1 Input AAA Output 3 1 3 2 2 3 1 7:35 */ import java.util.*; import java.io.*; public class PrefixesSuffixes { FastScanner in; PrintWriter out; class SuffixTree { int all, n; int[] parent; int[] suf; int[] depth; i...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
4267ea0dda0851b48859954c4dea5f44
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.io.*; public class PrefixesSuffixes { FastScanner in; PrintWriter out; class SuffixTree { final int m = 27; int[] str; int[] parent; int[] suf; int[] depth; int[][] link; int[] start; int[] sufNum; int withoutSuf = -1; int cur = 0; int cntNodes = 0; int n;...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
aee6b58c3800dc494aea6807b38c40dc
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
// http://codeforces.com/problemset/problem/432/D /* Input ABACABA Output 3 1 4 3 2 7 1 Input AAA Output 3 1 3 2 2 3 1 7:35 */ import java.util.*; import java.io.*; public class PrefixesSuffixes { FastScanner in; PrintWriter out; class SuffixTree { int m = 27; int[] parent; int[] depth; int[] suf; i...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
3a515c18c2fdc5d40ad9db27e2035787
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
// http://codeforces.com/problemset/problem/432/D /* Input ABACABA Output 3 1 4 3 2 7 1 Input AAA Output 3 1 3 2 2 3 1 */ import java.util.*; import java.io.*; public class PrefixesSuffixes { FastScanner in; PrintWriter out; class SuffixTree { final int m = 27; int[] str; int[] parent; int[] depth; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
c251d4e3afae324a4b7fde28f3122b3e
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.File; import java.util.ArrayList; import java.io.FilterInputStream; import java.util.C...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
80a94e338f5fd2aabbaf4885be866cda
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class code5 { InputStream is; PrintWriter out; static long mod=pow(10,9)+7; int arr[]; void solve() { String s=ns(); int n=s.length(); int z[]=new int[n]; zalgo(z,s); ArrayList<Integer> al=new ArrayList<Integer>(); ArrayList<Integer> s...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
b5c66f95990fbf76ab1f222b2f90d6b0
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import javax.sound.midi.Soundbank; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Tester { static class SuffixArray { private char str[]; private int MAX_LOG = 30; private int n, nr0[], nr1[], rank[][], index[], step, cnt; private int M; ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
c678b935cb47ec4d722c779574a6e503
train_000.jsonl
1400167800
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ...
256 megabytes
import java.io.*; import java.util.*; public class _432D { static List<Integer>[] g; static int[] size; static void dfs(int u, int parent) { size[u] = 1; for (int v : g[u]) if (v != parent) { dfs(v, u); size[u] += size[v]; } } ...
Java
["ABACABA", "AAA"]
1 second
["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"]
null
Java 8
standard input
[ "dp", "two pointers", "string suffix structures", "strings" ]
3fb70a77e4de4851ed93f988140df221
The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters.
2,000
In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in t...
standard output
PASSED
0eb725f1cb0399f06057c95bb094a128
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class TimofeyAndATree { InputStream is; PrintWriter pw; String INPUT = ""; long L_INF = (1L << 60L); List<Integer> g[]; void solve() { int n = ni(), x, y, m; g = new ...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
7b0cfb30af699dfa7f2d0b72e0f1ba92
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Vector; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution i...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
b2038657d32b0c159d4a6d51c4bb79d6
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
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
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
27bf4470f940e4caaac3b9bc2cff4832
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; // 15:26.000 + public class cf763a { static BufferedReader __in; static PrintWriter __out; static StringTokenizer input; static int par[], c[], sz[]; static int find(int i) { return p...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
bdb88a6eb431f36907138bd11210359d
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
/* ID: davidzh8 PROG: subset LANG: JAVA */ import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; // .--------------. // | Try First One| // '--------------' // | .--------------. // | | | // V ...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
e32d30c1abd4b9966d2957a3ebcb154d
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class A { public static int n; public static int col[]; public static List<Integer> adj[]; public static int edges[][]; public static int nxt = 0; public static boolean check = false; public static void main(String[] args)throws IOException { Fas...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
91639e293d4b64b72362513aec805fd0
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class A { static boolean dfs(int node, int par, ArrayList<Integer> l[]){ boolean ret = true; for(int adj : l[node]){ if(adj == par) continue; boolean flag = dfs(adj, node, l); ret...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
97334f9e3b23c8e218c981ace9e2c2ca
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.io.*; import java.util.*; public class A { static FastReader f = new FastReader(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args){ int n = f.nextInt(); ArrayList<Integer>[] edge = new ArrayList[n+1]; for(int i=0;i<=n;i++) { ...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
2f9e2c3657862907bb82b86bf90e398c
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
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.HashMap; import java.util.StringTokenizer; import java.util.TreeSet; impo...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
f001621bc3daa4d6e74ec223a427d400
train_000.jsonl
1486042500
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex ...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class GFG { static class edge{ int s,d,w; public edge(int s,int d,int w) { this.s=s; this.d=d; this.w=w; } } static class graph{ int v; LinkedLis...
Java
["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2"]
2 seconds
["YES\n2", "YES\n2", "NO"]
null
Java 11
standard input
[ "dp", "graphs", "dsu", "implementation", "dfs and similar", "trees" ]
aaca5d07795a42ecab210327c1cf6be9
The first line contains single integer n (2 ≤ n ≤ 105) — the number of vertices in the tree. Each of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, c2, .....
1,600
Print "NO" in a single line, if Timofey can't take the tree in such a way that it doesn't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them.
standard output
PASSED
8547a652f1c69eee0fd7ac311c32bacc
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
import java.util.*; import java.io.*; public class D1305{ static int n; static ArrayList<Integer>[] adjList; static boolean[] check; static boolean[] vis; static int global; public static void clean(int u, int p) { if(u == p) return; vis = new boolean[n]; int x = getNext(u, p); global = 1; vis = ...
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output
PASSED
95ee8d2962aae1b0241587b42af5f4eb
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
/* D A R K L _ _ O R D D A K / | | \ L O R D A R _ / | | \ _ K L O R D A R K _ / | _ | \ _ L ...
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output
PASSED
88b10a8a7968706fe6d4519825458d28
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
import java.io.*; import java.util.*; /* Прокрастинирую */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int INF = (int) (1e9 + 10); static final int MOD = (int) (1e9 + 7); static final int N = (int) (4e5 + 5); static fin...
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output
PASSED
cae1ab3c4e44e5f494cf5e6891260618
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.PriorityQueue; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayLis...
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output
PASSED
a38b612dab0fccfe977fd1dad3184a55
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); //Scanner sc = new Scanner(); Reader in = new Reader(); Main solver = new Main(); solver....
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output
PASSED
fef76f833df3b3aafb1e4829492b245a
train_000.jsonl
1583246100
This is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, and he's now lost!The United States of America can be modeled as a tree (why though) with...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Random; import java.util.StringTokenizer; publi...
Java
["6\n1 4\n4 2\n5 3\n6 3\n2 3\n\n3\n\n4\n\n4"]
1 second
["? 5 6\n\n? 3 1\n\n? 1 2\n\n! 4"]
NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The image below demonstrates the tree in the sample test:
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "trees", "interactive" ]
a291ee66980d8b5856b24d1541e66fd0
null
1,900
null
standard output