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
8dc17cfedd61713c2ad3574be7471061
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.*; public class file{ public static void main(String[] ags){ Scanner scan=new Scanner(System.in); int test=scan.nextInt(); for(int i=0;i<test;i++){ int a=scan.nextInt(); int[] arr=new int[a]; for(int j=0;j<a;j++){ arr[j]=scan.nextInt(); } Arrays.sort(arr); boolean flag=true; for(int j=a-1;j>=0;j--){ if...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
dcfdccc61f1cb4edc00f3dc7928ea6f0
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Solution{ public static void main(String...args) throws Exception { OutputStream outputStream =System.out; PrintWriter out =new PrintWriter(outputStream); Reader s=new Reader(); int T = s.nextInt(); whi...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
5adda3cee7fcaf5d3396033999e0fbb4
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class B1358 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int cases = scanner.nextInt(); for(int i = 0; i < cases; i++) { int length = scanner.nextInt(); int[] arrange = new int[length]; for(int j = 0; ...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
05ee1fb4dff6a0c53a24803e412a5dec
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import javax.print.DocFlavor; import java.util.*; import java.lang.*; import java.util.*; import java.util.stream.*; import java.io.*; import java.util.stream.Collectors; /* Name of the class has to be "Main" only if the class is public. */ public class common { public static void main(String[] args) throws java.l...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
5935cfcff9c55c584f1760bf3738efd3
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.io.*; import java.util.*; 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 arr[]=new int[n]; for(int i=0;i<n;i++) ...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
a8b99592213191bfe3017a2a7181b748
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); final int T = in.nextInt(); for (int t = 0; t < T; t += 1) { final int n = in.nextInt(); final long[] a = new l...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
325fd20f8af850da6fd2abd74763e8f4
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
/*package whatever //do not write package name here */ import java.util.*; import java.lang.*; import java.io.*; public class GFG { public static long fun(long arr[],int n){ Arrays.sort(arr); long c=1,m=1; for(int i=0;i<n;i++){ if(arr[i]<=c){ c++; m=c; ...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
7cbfd158134983691c6ffed0be816bc0
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.*; public class MariaBreakstheSelfIsolation { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t; t=sc.nextInt(); while(t-->0) { int n,i,count=1; n=sc.nextInt(); int a[]=new int[n]; for(i=0;i<n;i++) a[i]=sc.nextInt(); Array...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
2409b7dfdfa36a1a22a269e47927d90a
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
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 Main { // public static void swap(int a[],int i,int j) public static void main (String[] args) throws java.lang.Exceptio...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
1efe517666a061005fd9643445a3b5c0
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.Arrays; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; ...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
315cc82e38c1add46337ec66d37141b8
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class sol24 { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { ...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
59ba561485e6cbdcac0286138e0e959e
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.*; import java.io.*; public class code{ static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new Dat...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
bb8c2623a212222766ee95a9546a60d1
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; impo...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
408c6968d0c0a2b3fb8066c301d6e025
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.io.*; import java.util.*; public class CfA { static class Reader { BufferedReader br; StringTokenizer st; public Reader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreEle...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
22841c23ad38c6ab6dc2e478cbc12d74
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
//package asd; import java.util.Arrays; import java.util.Scanner; public class Demo2 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int x = s.nextInt(); while(x-->0) { int m = s.nextInt(); int[] g = new int[m]; for(int i=0;i<m;i++) { g[i]= s.nextInt(); } Arra...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
7fdd0ad2b7cafa2088c1e5fe23778881
train_001.jsonl
1590503700
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.She has $$$n$$$ friends who are also grannies (Maria is not included in this number). The $$$i$$$-th granny is ready to attend the ceremony, provided that at the time of her appea...
256 megabytes
import java.util.*; import java.util.Arrays; public class f { static Scanner sc=new Scanner(System.in); public static void main(String[] args) { int t=sc.nextInt(); for(int i1=0;i1<t;i1++) { int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n...
Java
["4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6"]
2 seconds
["6\n1\n6\n4"]
NoteIn the first test case in the example, on the first step Maria can call all the grannies. Then each of them will see five grannies when they come out. Therefore, Maria and five other grannies will be in the yard.In the second test case in the example, no one can be in the yard, so Maria will remain there alone.The ...
Java 8
standard input
[ "sortings", "greedy" ]
718cea81f609055cece58cae5310f703
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then test cases follow. The first line of a test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of grannies (Maria is not included in this number). The second line contains $$...
1,000
For each test case, print a single integer $$$k$$$ ($$$1 \le k \le n + 1$$$) — the maximum possible number of grannies in the courtyard.
standard output
PASSED
4605566e1dd9b782411c2cec919459f3
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.*; import java.util.*; public class A { static int n; static int[] arr; static char[] a, b; public static void main(String[] args) throws IOException { Flash f = new Flash(); int T = f.ni(); for(int tc = 1; tc <= T; tc++){ n = f.ni(); ...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
8ee3deb54623f2b40a249a46935c728c
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class C { public static PrintWriter out = new PrintWriter(System.out); public static Scanner in = new Scanner(System.in); public static void main(String[] args) { int t = ni(); while (t-- > 0) solve(); out.flush()...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
856a7aa6f429c571810ca64eebb2d255
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public final class C { public static void main(String[] args) { final Scanner in = new Scanner(new BufferedReader(new InputStreamRea...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
aaeda2fccceeadb8b5ee6bf97ea46664
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static void reverse(char[] arr, int len) { Stack<Character> st = new Stack<>(); for(int i = 0; i < len; i++) { char c = arr[i] == '0' ? '1' : '0'; ...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
62932224d747588b97d430798f2cc8ba
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t ...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
97981cd294abf56f063d84944ca46cf6
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.*; import java.util.*; /** * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools */ public class Main { public static void main(String[] args) { // Write your solution here Fa...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
1c329f1b0dc85e2ac1632d20bf11cb10
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; import java.io.*; /** * * @author billy */ public class PrefixFlip { static class Pair implements Compa...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
2570fb439b95d79e00ce4c4354032509
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.util.*; import java.io.*; public class Question3 { static FastReader sc = new FastReader(); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException{ int t = sc.nextInt(); while(t-->0) { solve(); } bw.flush...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
30a54289997c7fa98d8ca42c2f46b90c
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.util.*; public class Question3 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = sc.nextInt(); while(t-->0) { solve(); } } public static void solve() { int n = sc.nextInt(); char[] arr = new char[n]; char[] brr = new char[n]; arr = s...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
c7034e4c4a4f95c00b06367d6e9c8876
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
// package cp; import java.io.*; import java.math.*; import java.util.*; public class Cf_three { long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);} void swap(long a,long b) {long temp=a;a=b;b=temp;} StringBuilder sb=new StringBuilder(); BigInteger RES=new BigInteger("0"); // StringBuilder temp=new ...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
0dcd470f7ae8be75c6e6af930ce5b608
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; public class Task3 { public static void main(String[] args) throws IOException { new Task3().solve(); } private void solve(...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
6c033de19eec24ca59b780983a91d8cb
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
/* ------------------------------------------------------------------- * @Name: 1382C1 Prefix Flip (Easy Version) * @Author: Yanan * @Create Time: 2020/7/22 23:40:20 (UTC+08:00) * @Url: https://codeforces.com/contest/1382/problem/C1 * @Description: ----------------------------------...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
b68e766f7f424fc5d110f24e8b710419
train_001.jsonl
1595342100
This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cl...
Java
["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1"]
1 second
["3 1 2 1\n6 5 2 5 3 1 2\n0\n9 4 1 2 10 4 1 2 1 5\n1 1"]
NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.
Java 11
standard input
[ "data structures", "constructive algorithms", "strings" ]
10c9b2d70030f7ed680297455d1f1bb0
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binar...
1,300
For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.
standard output
PASSED
ef1cb5d017fa17ad00c2f380da44a0af
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashM...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 8
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
e1cf3eab5b16c90dd28ee558c39ad64a
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solution { private final static FastReader in = new FastReader(); private static final PrintWriter out = new PrintWriter(System.out); public static void...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 8
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
5188ef0c2012faa77f559bb371442e50
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solution { private final static FastReader in = new FastReader(); private static final PrintWriter out = new PrintWriter(System.out); public static void...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 8
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
00704760332e097b6b895cacf4acd647
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.stream.Collectors; import static java.lang.Integer.min; public class C369B { private static int n, k, l, r, sAll, sK; public static void main(String[] args) throws IOException { ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 8
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
777e8d3e968a1172c7e9f85f87b235de
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Solution implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) { new Thread(null, new ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
bceed52bfd4a2bb61c8a25bca81c7b5c
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class CFR2162 { public static void main (String[] args) { Scanner sc = new Scanner (System.in); int N = sc.nextInt(); int K = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int tsum = sc.nextInt(); int msum = sc.nextInt(); int[] answer = new int [N]; int ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
989092a0a362dd344addc88620c2e181
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Vector; public class ValeraAndContest { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line =...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
7ebc1fa2ecf42d0e04f82a1af4e5537d
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class T369B { public void solve(int n, int k, int l, int r, int sall, int sk) { int m =...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
8c36701901bdfdb7056a1c91ff81e65b
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.util.*; public class program { public static ArrayList<Integer> getPeople(int n, int min, int max, int sum) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = min; } int s = min * n; int i = 0; while (s != sum)...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
09f3b022bdc8399ade70c96048f3d1ff
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; publ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
3c38984fa9d2c238b5130f642ba07710
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner leer = new Scanner(System.in); int n, k, l, r, sall, sk; n = leer.nextInt(); k = leer.nextInt(); l = leer.nextInt(); r = leer.nextInt(); sall = leer.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
f117bccc1803b18207064ee429a44196
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; public class ValeraB { public static void main(String a[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(), l = in.nextInt(), r = in.nextInt(), sAll = in.nextInt(), sK = in.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
e4851bf1ea8e51af67657178a130ba98
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamReade...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
cc0d882b504039dc1a40655eebcb8893
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class Competitions { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); int low = scan.nextInt(); int high = scan.nextInt(); int sn = scan.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
c81699c570fae6212a6c32e69a411e13
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ if (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
eec05116bdff65055b0333af7c857fb4
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class p2_216 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); int Sall = in.nextInt(); int sk = in.nextInt...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
45b6e62f2bb4dc623b6af1a368600029
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class B { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public void solve() throws IOException { int N = nextInt(); int K = n...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
7c2627a6a22450055eafa962c5e708db
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
/** * Created by yuantian on 12/5/13. */ import java.util.*; public class ValeraAndContest369B { static public void main(String[] args) { Scanner in = new Scanner(System.in); int n, k, l, r, sa, sk; n = in.nextInt(); k = in.nextInt(); l = in.nextInt(); r = in.ne...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
257c9bdc34cff549d5281204cb0e7a38
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
/** * Created by yuantian on 12/5/13. */ import java.util.*; public class ValeraAndContest369B { static public void main(String[] args) { Scanner in = new Scanner(System.in); int n, k, l, r, sa, sk, sk1; n = in.nextInt(); k = in.nextInt(); l = in.nextInt(); r = ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
36d6b226a0540a346f0bd2bd94d44dba
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class B216 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); int sa = in.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
719dcacd95efe4eab4d09852adb07df1
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.util.*; public class B implements Runnable { private void solve() throws IOException { int n = nextInt(), k = nextInt(), l = nextInt(), r = nextInt(), sall = nextInt(), sk = nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] += l; sall -= l; } int need =...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
340b8d4d550084c193d35370729db669
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class B { public static void main(String args[]) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int l = s.nextInt(); int r = s.nextInt(); int sum = s.nextInt(); i...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
8012b216303f194aff99a5018f993b08
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author smith */ public class B { public static void main(String Args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
6fbcef9b551b472c4a42c0cf4da0795d
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; public class Contest { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n, k, l, r, sall, sk; n = in.nextInt(); k = in.nextInt(); l = in.nextInt(); r = in.nextInt(); sall = in.nextInt(); sk = in.nextInt(); int[] arr = ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
b64fe64d1f7280aa3cc98c50fd78875a
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(System.in); //Scanner sc = new Scanner(new File("input.txt")); // n, k, l, r, sall, sk int n = sc.ne...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
46a36d0c245c396010743202b70f1451
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by 875k on 12/23/13. */ public class CF216B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamRead...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
177cdafe6d53dbb6e5e4c6135df7f6da
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; import java.awt.geom.*; import java.io.*; public class Main{ private void doit(){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int k = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt()...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
9a2c62588b0ac107acde4a7cf1916d89
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; import java.io.*; public class prog{ public static int tot=0,k=0,l = 0,r=0,sa=0,sk=0; public static boolean llegue = false; public static void hagale(int a,Vector<Integer> b,int sum){ if(llegue)return; if(a==tot && sum==sa){ llegue=true; StringBuilder sb = new StringBuilder(""); for(int n = 0;n<b.si...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
00b4223b027c3e81686abc8ae26d92d0
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class B216 { public void solve() throws IOException { Scanner sc = new Scanner(System.in); BufferedReader br = new Bu...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
2ee697f968977abeb9fae10865cf1ca6
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class R216B { static InputStream is; static PrintWriter out; static String INPUT = ""; public static int func(int[] a) {...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
4867249954777cd4063cbe591d13c498
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.util.*; public class B216 { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] inputStr = in.readLine().split(" "); int[] a = new int[6]; for (int i = 0; i < 6; i++) a[i] = pi(inputStr[i]); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
82d8e4536a2623cbf588f8a11eb84883
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.util.*; public class a { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = input.nextInt(), k = input.nextInt(), l = input.nextInt(), r = input.nextInt(); int sall = input.nextInt()...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
1e5f580e20451aa851850bd106fea722
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
9838805ae2f37799431d83782f430b6a
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; import java.io.PrintStream; public class TaskB{ public static void main(String[] argc){ Scanner in = new Scanner(System.in); PrintStream out = System.out; int n, k, l, r, sall, sk; n = in.nextInt(); k = in.nextInt(); l = in.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
a5b8f4ed6b549ac3e296bc54504ff18d
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemB { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
6a6ef5227dba4c58d0058a78b6570ae0
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outpu...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
27d9f77453084acda30be339ed93c6f3
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * Built using CHelper plug-in * Actual solution is at the top * @author coderbd */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Inpu...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
83864ddb432391592f60ea153bd39bdd
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import javax.print.attribute.standard.MediaSize.ISO; public class Codeforces2 implements Runnable { private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringT...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
7039ac4336e7aaa9baea232660887533
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int min = sc.nextInt(); int max = sc.nextInt(); int ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
de52c0828ed6159848145f192df9d0af
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.*; import java.io.*; public class TeamContest { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(rd.readLine()); int n = ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
383f395cacae881a330f2490b4ec93e8
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class B { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int k = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int sall = sc.nextInt(); int sk = sc.nextInt();...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
b1765bb35f118fdc602c127af1d5e8c8
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
//369B import java.io.*; import java.util.*; public class contest { public static void main(String args[])throws IOException {Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); int sall=sc.nextInt(); int sk=sc.nextInt(); int x=sk/k; int a[]=new int[n]; int...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
261bcbe9f0abeaad8961e8b775187322
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author pttrung */ public class B { public static ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
04bfe1742178b466abd67634e5ed551a
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class B { public static void main(String[] args) { (new B()).run(); } void run() { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int l = in.nextInt(); ...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
182a404bed86816c9de72ac8e9ca87c4
train_001.jsonl
1385739000
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.After the contest was over, Valera wa...
256 megabytes
import java.util.Scanner; public class ValeraandContest { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); int l = input.nextInt(); int r = input.nextInt(); int sAll = input.nextInt(); int sK = input.nextInt(); int temp...
Java
["5 3 1 3 13 9", "5 3 1 3 15 9"]
1 second
["2 3 2 3 3", "3 3 3 3 3"]
null
Java 6
standard input
[ "constructive algorithms", "implementation", "math" ]
59154ca15716f0c1c91a37d34c5bbf1d
The first line of the input contains exactly six integers n, k, l, r, sall, sk (1 ≤ n, k, l, r ≤ 1000; l ≤ r; k ≤ n; 1 ≤ sk ≤ sall ≤ 106). It's guaranteed that the input is such that the answer exists.
1,400
Print exactly n integers a1, a2, ..., an — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.
standard output
PASSED
d9dfd96073a0ec56e2a013d1a5c6c012
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class MaxDistributionTree { public static void main(String[] args) { long timeStart = System.nanoTime(); Utility.FastReader fr = new Utility.FastReader(); Solver solver = ...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
b7417f2643bbd27cb9b68be3c3963885
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.util.*; import java.math.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); final long MOD = 1000000007L; int t = in.nextInt(); for(int tt = 0; tt < t; tt++) { long ans = 0L; int n = in.nextInt(); Node[] nodes = new Node[n]; List<Lon...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
3ed5950d0bca0a0bc5d2dcd9f0ec9bf2
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(n...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
854c90464f96c0e6c5bc51b717c94e96
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.util.*; import java.io.*; public class Question4My { static HashSet<Integer> nodes[]; static boolean vis[]; static int n; static int subtreeSize[]; static ArrayList<Long> list; static int MOD = (int)(1e9 + 7); static Reader sc = new Reader(); public static void main(String[] args) throws IOExc...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
86ab3e2fba114bbed1834fa6a7a23026
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.util.*; import java.io.*; public class Question4My { static HashSet<Integer> nodes[]; static boolean vis[]; static int n; static long subtreeSize[]; static ArrayList<Long> list; static int MOD = (int)(1e9 + 7); static Reader sc = new Reader(); public static void main(String[] args) throws IOEx...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
4d4c8d9f266b3f34dce1b328b47077e4
train_001.jsonl
1598020500
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Task4 { ArrayList<Integer>[] adj; long[] subtreeSize; long[] edgeTraversals; int n; int mod; public static void main(String[] args) throws I...
Java
["3\n4\n1 2\n2 3\n3 4\n2\n2 2\n4\n3 4\n1 3\n3 2\n2\n3 2\n7\n6 1\n2 3\n4 6\n7 3\n5 1\n3 6\n4\n7 5 13 3"]
2 seconds
["17\n18\n286"]
Note In the first test case, one of the optimal ways is on the following image: In this case, $$$f(1,2)=1$$$, $$$f(1,3)=3$$$, $$$f(1,4)=5$$$, $$$f(2,3)=2$$$, $$$f(2,4)=4$$$, $$$f(3,4)=2$$$, so the sum of these $$$6$$$ numbers is $$$17$$$. In the second test case, one of the optimal ways is on the following image: I...
Java 11
standard input
[ "dp", "greedy", "number theory", "math", "implementation", "sortings", "dfs and similar", "trees" ]
968b3db21bd16bc04bdb355e98079d5d
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines describes an edge: the $$$i$$$-th line contains two integers $$$...
1,800
Print the maximum distribution index you can get. Since answer can be too large, print it modulo $$$10^9+7$$$.
standard output
PASSED
83df445dfe26946a2219ae1616da661c
train_001.jsonl
1591281300
Johnny has a new toy. As you may guess, it is a little bit extraordinary. The toy is a permutation $$$P$$$ of numbers from $$$1$$$ to $$$n$$$, written in one row next to each other. For each $$$i$$$ from $$$1$$$ to $$$n - 1$$$ between $$$P_i$$$ and $$$P_{i + 1}$$$ there is a weight $$$W_i$$$ written, and those weights ...
1024 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Ran...
Java
["3\n3 2 1\n2 1\n3\n1 3\n3 2\n3 1", "5\n4 3 2 5 1\n3 2 1 4\n7\n5 4\n5 2\n1 5\n2 4\n2 4\n4 3\n3 3"]
15 seconds
["0\n1\n0", "3\n1\n2\n1\n2\n3\n3"]
NoteConsider the first sample. After the first query, $$$P$$$ is sorted, so we already achieved a permutation with no inversions. After the second query, $$$P$$$ is equal to [$$$1$$$, $$$3$$$, $$$2$$$], it has one inversion, it can be proven that it is impossible to achieve $$$0$$$ inversions. In the end, $$$P$$$ is eq...
Java 11
standard input
[ "data structures", "implementation", "math" ]
354f3e98fefb325b8503be21c84ac4ef
The first line contains single integer $$$n$$$ $$$(2 \leq n \leq 2 \cdot 10^5)$$$ denoting the length of the toy. The second line contains $$$n$$$ distinct integers $$$P_1, P_2, \ldots, P_n$$$ $$$(1 \leq P_i \leq n)$$$ denoting the initial permutation $$$P$$$. The third line contains $$$n - 1$$$ distinct integers $$$W_...
3,300
Output $$$q$$$ lines. The $$$i$$$-th line should contain exactly one integer — the minimum number of inversions in permutation, which can be obtained by starting with the $$$P$$$ after first $$$i$$$ queries and making moves described in the game's instruction.
standard output
PASSED
12761ffab5b7357ceec55f46309130b1
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.io.*; public class A { static PrintWriter ww = new PrintWriter(System.out); static class Pair{ long extra , max , leaves; public Pair(long leaves , long max , long extra){ this.leaves = leaves; this.max = max; this.extra = extr...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
1c15f6fc6ddf3ef138ddc694e7fe0ca3
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * @author khokharnikunj...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
95f2906b98fd413710ffda92373db93b
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.*; import java.util.*; /** * Created by Katushka on 11.03.2020. */ public class Main { static int[] readArray(int size, InputReader in) { int[] a = new int[size]; for (int i = 0; i < size; i++) { a[i] = in.nextInt(); } return a; } static long[]...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
afcf3d33b4af836540e798a59fe046af
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
bd3139803cc9fb58c23c95f0292d324e
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.awt.Point; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; imp...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
89e154bf24627ce0bf74ab86ddb552ff
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.*; import java.util.*; public class Main1 { public static final int mod=1000000007; public static List<Integer>[] g; public static int[] arr; public static void main(String[] args) throws IOException { //File filein = new File("input.txt"); //BufferedReader sc=new BufferedReader(new FileRe...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
5eaad3f9e9d8235a55fe1fb49c611573
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.*; import java.util.*; public class Main { static ArrayList<Integer> adj[]; static int k; static int[] a; static int b[]; static int m; static class Pair implements Comparable<Pair> { long a; long b; public Pair(long c, long l) { a = c; b = l; } @Override public int compareTo(P...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
6f0267ba68ec2049ef4def2098cead9a
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.PriorityQueue; import j...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
631956ff7a5d881be6ad15cdcc8594e2
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
// No sorcery shall prevail. // import java.util.*; import java.io.*; public class _InVoker_ { //Variables static long mod = 1000000007; static long mod2 = 998244353; static FastReader inp= new FastReader(); static PrintWriter out= new PrintWriter(System.out); public static void main(String args[]) { ...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
21ae4420606f95456586428620cc588e
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.io.*; public class D_1436 { static ArrayList<Integer>[] adjList; static int[] a; public static Tuple dfs(int u) { if(adjList[u].size() == 0) return new Tuple(1, a[u], a[u]); Tuple x = new Tuple(0, 0, 0); for(int v : adjList[u]) { Tuple y = dfs(v); if(x.max >= y....
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
f97b74e62ce26b83b2fcac2229c97a62
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); long mod = 998244353; List<Integer>[] tree; long[] sum_...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
589360094507811395228d9cf9aee1db
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
// package NickMikeMurderers; import java.io.*; import java.util.ArrayList; public class BanditCity { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader(...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
5ab55c7c2a003ddda770096cea8a0fd3
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gcd(long a,long...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
ee3e1792dfecd0e976987ac5357b6097
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.io.BufferedOutputStream; 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.List; import java.util.StringTokenizer; public class D { //-------------------------...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
966b893a06827d31c6578f20e64b665a
train_001.jsonl
1603548300
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of $$$n$$$ squares connected by $$$n-1$$$ roads in such a way that it is possible to reach any square from any other square. The square number $$$1$$$ is the main square.After Sunday walk all the roads were changed...
256 megabytes
import java.util.*; import java.io.*; public class D445 { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////...
Java
["3\n1 1\n3 1 2", "3\n1 1\n3 1 3"]
1 second
["3", "4"]
NoteIn the first example the citizens on the square $$$1$$$ can split into two groups $$$2 + 1$$$, so that the second and on the third squares will have $$$3$$$ citizens each.In the second example no matter how citizens act the bandit can catch at least $$$4$$$ citizens.
Java 8
standard input
[ "greedy", "graphs", "binary search", "dfs and similar", "trees" ]
18cf79b50d0a389e6c3afd5d2f6bd9ed
The first line contains a single integer $$$n$$$ — the number of squares in the city ($$$2 \le n \le 2\cdot10^5$$$). The second line contains $$$n-1$$$ integers $$$p_2, p_3 \dots p_n$$$ meaning that there is a one-way road from the square $$$p_i$$$ to the square $$$i$$$ ($$$1 \le p_i &lt; i$$$). The third line contain...
1,900
Print a single integer — the number of citizens the bandit will catch if both sides act optimally.
standard output
PASSED
48e026c14c5223e88b8a80fa0921d4a3
train_001.jsonl
1595342100
You are given two arrays of integers $$$a_1,\ldots,a_n$$$ and $$$b_1,\ldots,b_m$$$.Your task is to find a non-empty array $$$c_1,\ldots,c_k$$$ that is a subsequence of $$$a_1,\ldots,a_n$$$, and also a subsequence of $$$b_1,\ldots,b_m$$$. If there are multiple answers, find one of the smallest possible length. If there ...
256 megabytes
import java.io.*; import java.util.*; public class A { static int n, m; static int[] arr, brr; static char[] s; public static void main(String[] args) throws IOException { Flash f = new Flash(); int T = f.ni(); for(int tc = 1; tc <= T; tc++){ n = f.ni(); m = f.ni...
Java
["5\n4 5\n10 8 6 4\n1 2 3 4 5\n1 1\n3\n3\n1 1\n3\n2\n5 3\n1000 2 2 2 3\n3 1 5\n5 5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\n1 4\nYES\n1 3\nNO\nYES\n1 3\nYES\n1 2"]
NoteIn the first test case, $$$[4]$$$ is a subsequence of $$$[10, 8, 6, 4]$$$ and $$$[1, 2, 3, 4, 5]$$$. This array has length $$$1$$$, it is the smallest possible length of a subsequence of both $$$a$$$ and $$$b$$$.In the third test case, no non-empty subsequences of both $$$[3]$$$ and $$$[2]$$$ exist, so the answer i...
Java 11
standard input
[ "brute force" ]
776a06c14c6fa3ef8664eec0b4d50824
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1\le n,m\le 1000$$$)  — the lengths of the two arrays. The second line of each test ...
800
For each test case, output "YES" if a solution exists, or "NO" otherwise. If the answer is "YES", on the next line output an integer $$$k$$$ ($$$1\le k\le 1000$$$)  — the length of the array, followed by $$$k$$$ integers $$$c_1,\ldots,c_k$$$ ($$$1\le c_i\le 1000$$$)  — the elements of the array. If there are multiple s...
standard output
PASSED
587b7c8e0dbc7227ab09c9586ee9851f
train_001.jsonl
1595342100
You are given two arrays of integers $$$a_1,\ldots,a_n$$$ and $$$b_1,\ldots,b_m$$$.Your task is to find a non-empty array $$$c_1,\ldots,c_k$$$ that is a subsequence of $$$a_1,\ldots,a_n$$$, and also a subsequence of $$$b_1,\ldots,b_m$$$. If there are multiple answers, find one of the smallest possible length. If there ...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); int m=sc.nextInt(); int flag=0; ArrayList<Integer> list1=new ArrayList<Integer>(); ...
Java
["5\n4 5\n10 8 6 4\n1 2 3 4 5\n1 1\n3\n3\n1 1\n3\n2\n5 3\n1000 2 2 2 3\n3 1 5\n5 5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\n1 4\nYES\n1 3\nNO\nYES\n1 3\nYES\n1 2"]
NoteIn the first test case, $$$[4]$$$ is a subsequence of $$$[10, 8, 6, 4]$$$ and $$$[1, 2, 3, 4, 5]$$$. This array has length $$$1$$$, it is the smallest possible length of a subsequence of both $$$a$$$ and $$$b$$$.In the third test case, no non-empty subsequences of both $$$[3]$$$ and $$$[2]$$$ exist, so the answer i...
Java 11
standard input
[ "brute force" ]
776a06c14c6fa3ef8664eec0b4d50824
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1\le n,m\le 1000$$$)  — the lengths of the two arrays. The second line of each test ...
800
For each test case, output "YES" if a solution exists, or "NO" otherwise. If the answer is "YES", on the next line output an integer $$$k$$$ ($$$1\le k\le 1000$$$)  — the length of the array, followed by $$$k$$$ integers $$$c_1,\ldots,c_k$$$ ($$$1\le c_i\le 1000$$$)  — the elements of the array. If there are multiple s...
standard output
PASSED
4d3a1adb80cd7c43b406bbc89470a40b
train_001.jsonl
1595342100
You are given two arrays of integers $$$a_1,\ldots,a_n$$$ and $$$b_1,\ldots,b_m$$$.Your task is to find a non-empty array $$$c_1,\ldots,c_k$$$ that is a subsequence of $$$a_1,\ldots,a_n$$$, and also a subsequence of $$$b_1,\ldots,b_m$$$. If there are multiple answers, find one of the smallest possible length. If there ...
256 megabytes
import java.util.*; import java.util.Arrays; public class Main { public static void main(String args[]) { try { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t>=0) { int m=in.nextInt(); int n=in.nextInt(); ...
Java
["5\n4 5\n10 8 6 4\n1 2 3 4 5\n1 1\n3\n3\n1 1\n3\n2\n5 3\n1000 2 2 2 3\n3 1 5\n5 5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\n1 4\nYES\n1 3\nNO\nYES\n1 3\nYES\n1 2"]
NoteIn the first test case, $$$[4]$$$ is a subsequence of $$$[10, 8, 6, 4]$$$ and $$$[1, 2, 3, 4, 5]$$$. This array has length $$$1$$$, it is the smallest possible length of a subsequence of both $$$a$$$ and $$$b$$$.In the third test case, no non-empty subsequences of both $$$[3]$$$ and $$$[2]$$$ exist, so the answer i...
Java 11
standard input
[ "brute force" ]
776a06c14c6fa3ef8664eec0b4d50824
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1\le n,m\le 1000$$$)  — the lengths of the two arrays. The second line of each test ...
800
For each test case, output "YES" if a solution exists, or "NO" otherwise. If the answer is "YES", on the next line output an integer $$$k$$$ ($$$1\le k\le 1000$$$)  — the length of the array, followed by $$$k$$$ integers $$$c_1,\ldots,c_k$$$ ($$$1\le c_i\le 1000$$$)  — the elements of the array. If there are multiple s...
standard output
PASSED
44f35a0beea830f1c50f03e540f4975b
train_001.jsonl
1595342100
You are given two arrays of integers $$$a_1,\ldots,a_n$$$ and $$$b_1,\ldots,b_m$$$.Your task is to find a non-empty array $$$c_1,\ldots,c_k$$$ that is a subsequence of $$$a_1,\ldots,a_n$$$, and also a subsequence of $$$b_1,\ldots,b_m$$$. If there are multiple answers, find one of the smallest possible length. If there ...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int as...
Java
["5\n4 5\n10 8 6 4\n1 2 3 4 5\n1 1\n3\n3\n1 1\n3\n2\n5 3\n1000 2 2 2 3\n3 1 5\n5 5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\n1 4\nYES\n1 3\nNO\nYES\n1 3\nYES\n1 2"]
NoteIn the first test case, $$$[4]$$$ is a subsequence of $$$[10, 8, 6, 4]$$$ and $$$[1, 2, 3, 4, 5]$$$. This array has length $$$1$$$, it is the smallest possible length of a subsequence of both $$$a$$$ and $$$b$$$.In the third test case, no non-empty subsequences of both $$$[3]$$$ and $$$[2]$$$ exist, so the answer i...
Java 11
standard input
[ "brute force" ]
776a06c14c6fa3ef8664eec0b4d50824
The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1\le n,m\le 1000$$$)  — the lengths of the two arrays. The second line of each test ...
800
For each test case, output "YES" if a solution exists, or "NO" otherwise. If the answer is "YES", on the next line output an integer $$$k$$$ ($$$1\le k\le 1000$$$)  — the length of the array, followed by $$$k$$$ integers $$$c_1,\ldots,c_k$$$ ($$$1\le c_i\le 1000$$$)  — the elements of the array. If there are multiple s...
standard output