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
082558f9b33596477f7218e62ea9fa6d
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.*; public class tmp { public static void main(String [] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); int min = 0, max= n+1; for(int i=1; i<=k; i++){ if(i%2 == 0){ max = (...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
21d2ae3e03c3be1f28eab8b486aba600
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
//package round275; 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 A { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), K = n...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
eb9cff744fd7c01ae9eff434685b6cfb
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Mahmoud Aladdin <aladdin3> */ public ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
840ab5bdb364e6c50f692ce8c0d3f923
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * TODO: Insert description here. (generated by mfahim) */ public class Round275_Div1_A { public static void main(String[] args) throws Exception { int n = nextInt(); int k = n...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
98fff982f79531db3029dcbf719ce64f
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class DiversePermutation { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.i...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
fa73b87a0d6754d79f69753e2b4f6fc8
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.*; import java.util.*; public final class diverse_perm { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); static boolean[] v; static int[] a; static int n,k; static void solve() { boolean b1=true,b2=false; a[1]=1; int i; v[1]=true; for(i=2;i...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
74663192322334f997bc350affdb539b
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int k = sc.nextInt(); if (k % 2 ==...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
ad89f00b755e872b0369d93436a5a0f3
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; public class Permutations { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); for (int i = 1; i < n - k; i++) { System.out.print(i + " "); } int s = n - k; int sign = 1; int c = k; ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
a41f409e78d8d9bbdbd7fa483e56fc5f
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.*; import java.util.*; public class Main { // main public static void main(String [] args) throws IOException { // makes the reader and writer BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
f61a357d518b52b815f236748dce6ee8
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Tifuera */ public class Main { public static void main(Strin...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
9f7990308bc538ea06207e641497ea78
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { public static void main(String[] args) { try { InputScanner scanner = new InputScanner(); int n = scanner.nextInt(); int k = ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
3daffb884e070dfc5eb7a0c484bbb71c
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
/* Problem: find an order of the permutation of digits < n of length n such that |p1-p2|, |p2-p3|, ... |pn-1 - pn| has exactly k distinct values. Solution: Greedy. First noteyou can create a successive string of 1s by going in ascending or descending order Then note you can get unique numbers, ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
be5d4cfffe2caae5707243393e0e2b38
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
public class T { private int n, k; protected void solve() { out.print(n); int i = n - 1, j = 1; for (int m = 0; m < k - 1; m++) { out.print(" "); out.print(j); if (j < i) j++; else j--; int t = j; j = i; i = t; } ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
d1853593aa64b09d7dd1a623b34a4ef1
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; public class DiversePermutations { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); for(int i=1;i<=n-k;i++) { System.out.print(i+" "); } int stop=n-k+1; int last=n; for(int i=n-k+1;i<=n;i=i+2) {...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
4576498368e41f206dc36cfe53ef457a
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; public class Diverse { public static void main(String[]args){ Scanner in=new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] A = new int[n]; A[0] = 1; int f = 1; int i; for (i = 1; i <= k; i++) { A[i] = A[i - 1] + f...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
44860681c1405c37dd0ed5db055c73fc
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws Exception { new A().solve(); } void solve() throws IOException { FastScanner in = new FastScanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] p ...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
b9ee5fd3a70c0fc1133cd67df32763f2
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; public class Solution { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int index = 0; int next = 1;...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
c4d1090bf8aad546431a407a02d6f242
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author mongsiry013 */ public class Main { public static void main(String[] args) { InputStream inputStre...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
b22c1a575d9fcab2677712039a4f3431
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class A { void run() throws IOException { int n = ni(), k = ni(); int[] d = new int[n]; int a = 1 - k, b = 1, c = n - k; while (c < n) { d[c++] = a; a += 3; if (c == n) { break; } d[c++]...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
02e849d54bf0d16171dc6731bd698406
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.util.Scanner; public class A482 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int K = in.nextInt(); StringBuilder ans = new StringBuilder(); int num = 1; boolean add = true; for (int i = K; i...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
aff0fd47f821cae7908f3537c7853884
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.*; import java.util.*; import java.util.List; public class Main { private static StringTokenizer st; private static BufferedReader br; public static long MOD = 1000000007; public static long tenFive = 100000; public static double EPS = 0.000000001; public static void print(Objec...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
b32368243a7ea100f0d578a4c28a4200
train_002.jsonl
1414170000
Permutation p is an ordered set of integers p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,โ€‰โ€‰โ€‰p2,โ€‰โ€‰โ€‰...,โ€‰โ€‰โ€‰pn.Your task is to find such permutation p of length n, that the group of numbers |p1โ€‰-โ€‰p2|,โ€‰|p2โ€‰-โ€‰p3|,โ€‰...,โ€‰|pnโ€‰-โ€‰1โ€‰-โ€‰pn| has e...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Locale; import java.util.StringTokenizer; public class A { private static BufferedReader in; private static St...
Java
["3 2", "3 1", "5 2"]
1 second
["1 3 2", "1 2 3", "1 3 2 4 5"]
NoteBy |x| we denote the absolute value of number x.
Java 7
standard input
[ "constructive algorithms", "greedy" ]
18b3d8f57ecc2b392c7b1708f75a477e
The single line of the input contains two space-separated positive integers n, k (1โ€‰โ‰คโ€‰kโ€‰&lt;โ€‰nโ€‰โ‰คโ€‰105).
1,200
Print n integers forming the permutation. If there are multiple answers, print any of them.
standard output
PASSED
cf639b38ced245a6837397414d9caa23
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
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.StringTokenizer; public class pr883H { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out =...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
dc80920e09a0788125424980a4bbda0e
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class H { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String word = sc.next(); Map<Character, Integer> count = new HashMap<>(); for (Cha...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
961dee93e487d2606528038449afc750
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); ArrayList<StringBuilder> list = new ArrayList<>(); ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
cf447de1e14ec4237d28fdd615f46dfd
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.*; import java.io.*; public class Q1 { static InputReader in=new InputReader(System.in); static PrintWriter out=new PrintWriter(System.out); static int T=1,N,M; static int A[]; static int dp[][]; static ArrayList<Integer> graph[]; public static void main(String args[]) { //T=in.readInt(); ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
d6a588ad20fa733b07a4d8e21228049b
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.AbstractCollection; import java.util.StringTokenizer; import java.io.BufferedReader; import java...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
7e2d747e9e5597bfaed107a2e71b6ff0
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class main { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter pw = new PrintWriter(System.out); public static String line; public static StringTokenizer st; public stati...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
1be0d6aa984cdcf413b72cbf9d055607
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P883H { List<String> makePalindromes(Deque<Character> od, TreeMap<Character, Integer> em, int k, int l) { List<String> sl = new ArrayList(k); char [] s = new char [l]; while ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
ec91df3f29b4582e704bd6d7a3a2e352
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.util.*; public class MainH { public static void main(String[] args) { StdIn in = new StdIn(); int n=in.nextInt(); int[] cnt = new int[256]; String s = in.next(); for(char c : s.toCharArray()) ++cnt[c]; List<Character> oddEntries = new ArrayList<Character>(); for(int i=...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
a1143a882816794b114b7e78e2d8d897
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.util.*; public class MainH { public static void main(String[] args) { StdIn in = new StdIn(); int n=in.nextInt(); int[] cnt = new int[256]; String s = in.next(); for(char c : s.toCharArray()) ++cnt[c]; List<Character> oddEntries = new ArrayList<Character>(); for(int i=...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
db74c73da2eaa49df8bc878e70b873f2
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Out...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
45bb82845a67d302d6ada6a198bd9ed6
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class TaskH { private static BufferedReader in; private static StringTokenizer tok; private static PrintWriter out; public static String readToken() thro...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
b5113d9b66b8f6507c2008fcb4d87cc8
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); Thread th = new Thread(null, new Runnable(){public void run(){n...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
8b7f4e27adcebfeec55b2078dcd28063
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.*; import java.io.*; public class ProblemH { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); int n ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
b33ca55d5f7ec215089365d10b054f95
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.*; public class Problem883H { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String s = in.next(); Map<Character, Integer> freq = new HashMap<>(2 * 26 + 10); for (int i = 0; i < n; i++) { freq.compute(s.charAt(i), (k, v) ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
743cd5eeb928d4937eb9f82facfa9a30
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.AbstractCollection; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.LinkedList; import java.io...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
b864bd0fcb5b66a1ec9e8e3a419bee38
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; /** * Created by dtnha on 10/20/2017. */ public class PalindromicCut { public static void main(String[] args) throws IOException { Reader.init(System.in); ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
cc694f16c0b4399c847162f398b1f54a
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; import java.io.*; public class TestClass{ static class Parser { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
ccee0767a6c5281860c256f30883d4eb
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; import java.io.*; public class TestClass{ static class Parser { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
03d9c167ff1e449dca6061cc3173ff39
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
6315c7e7d9a230e4f886f15d0d570581
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.*; import java.io.*; /** * @author me **/ public class Test { public static void main(String[] args) { Scanner scannered = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = scannered.nextInt(); String s = scannered.next(); int[] c...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
acfb9355182d7236ea8a77df2adf64ae
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception { MyReader reader = new MyReader(System.in); MyWriter writer = new MyWriter(System.out); new Solution().run(reader, writer); writer.close(); } private void...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
28b334ea1d51b25e3068af1d96df34cf
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class m { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
b74d464595a187f62e6b4e9c7bedd7be
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the templ...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
5553510344cc24550833c33591e25042
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
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.Collections; import java.util.StringTokenizer; public class H_ { public static void main(String[] args) throws IOException { Scanner sc = new Scanner...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
624afb7b5161837c50b2c671bbadb025
train_002.jsonl
1508573100
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, suc...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["6\naabaac", "8\n0rTrT022", "2\naA"]
3 seconds
["2\naba aca", "1\n02TrrT20", "2\na A"]
null
Java 8
standard input
[ "implementation", "brute force", "strings" ]
d062ba289fd9c373a31ca5e099f9306c
The first line contains an integer n (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰4ยท105) โ€” the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.
1,800
Print to the first line an integer k โ€” minimum number of palindromes into which you can cut a given string. Print to the second line k strings โ€” the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
standard output
PASSED
2eb5efc21523804e34142a4eb0e83403
train_002.jsonl
1494860700
Digital collectible card games have become very popular recently. So Vova decided to try one of these.Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck with total power not less than k, but magic numbers may not allow him t...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static final int INF = (int)1e9; static int V, s, t; //s != t static ArrayList<Integer>[] adjList; static int[][] res; //instead of res, you can use c[][], f[][] so as not to destroy the graph static int[] p; //res (residual) = c (capacity) - f (flow...
Java
["5 8\n5 5 1\n1 5 4\n4 6 3\n1 12 4\n3 12 1", "3 7\n4 4 1\n5 8 2\n5 3 3"]
2 seconds
["4", "2"]
null
Java 11
standard input
[ "binary search", "flows", "graphs" ]
de725cbd81d17d8e44c766e7b7e23f3d
The first line contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100, 1โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰100000). Then n lines follow, each of these lines contains three numbers that represent the corresponding card: pi, ci and li (1โ€‰โ‰คโ€‰piโ€‰โ‰คโ€‰1000, 1โ€‰โ‰คโ€‰ciโ€‰โ‰คโ€‰100000, 1โ€‰โ‰คโ€‰liโ€‰โ‰คโ€‰n).
2,400
If Vova won't be able to build a deck with required power, print โ€‰-โ€‰1. Otherwise print the minimum level Vova has to reach in order to build a deck.
standard output
PASSED
655ca938bc417ff19e63d5a8b216f1e5
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); int d = s.nextInt(); int h = s.nextInt(); if (2 * h < d || (h == 1 && d == 1 && n > 2)){ System.out.println("-1");...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
c786eaeb04095ada86624e2230002316
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
//package CF; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { static int INF = (int) 1e9 + 7; public static void main(String[] args) thr...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
999f458fae6769aefd6ca36d4badd396
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; import java.util.ArrayList; public class Test { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(), d=scan.nextInt(), h=scan.nextInt(); if (d>h+h || d<h || (d==1 && n>2)) System.out.println(-1); else { for (int i=1; i<=h; i++...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
9470615b0d941d9f7fbe8980de579800
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * @author muhossain * @since 2020-02-11 */ public class B639 { public static void main(String[] args) { FastScanner fs =...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
63d0ff281dcd232b23d893d4d6e957b5
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * @author muhossain * @since 2020-02-11 */ public class B639 { public static void main(String[] args) { FastScanner fs =...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
ae7fe25bd2f183b37dfb11bc629a51af
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class C658 { private static boolean home = !"true".equals(System.getProperty("ONLINE_JUDGE")); private static boolean debug = false; public static ...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
6e0fcb0be1ddadd11c50ab03c5425d1e
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { public static void main(String[] args) thro...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
0f28fffce47c1c8c252795d3f69f70b3
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
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 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
890fe101e4398e53796842831b905ae7
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; public class Tree{ public static void main(String [] args){ Scanner sc=new Scanner(System.in); int n=0; int d=0; int h=0; n=sc.nextInt(); d=sc.nextInt(); h=sc.nextInt(); if(d>2*h || d<h || (d==1 && n>2)) {System.out.println("-1");} else { for(int i=0; i<h;i++) { System.out.print(...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
f09c53b8a2a70339c72028fa46061036
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.*; import java.io.*; /** * * @author umang */ public class B639 { public static int mod = 1000000007; public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); ...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
b72feac6960e62c7e734c931209cccba
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
/** * * @author sarthak */ import java.util.*; import java.math.*; import java.io.*; public class rnd132_C { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(InputStream is) { br = new BufferedReader(new InputStreamReader(is)); ...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
982719a2d383a8855a437273cc781ee4
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B639 { static BufferedReader br; static StringTokenizer st; static PrintWriter pw; static String nextToken() { try { ...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
d6bcbb84fde6bd7fe37b46808aa4aa3d
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.StringToken...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
0bc548a3eaf89f26fc1bf15dc8a2ae7f
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; public class BearAndTree { public static void main(String[] args) { Scanner input = new Scanner(System.in); int numberOfVertices = input.nextInt(); int diameterOfTree = input.nextInt(); int heightBetweenVertices = input.nextInt(); searchOfPath(nu...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
d2b10ae8c443357cee0319aa9c7de3b7
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class BearAndTheForgottenTree { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Sys...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
4c6d182d34ccaa1b26a4c0651fa0fb59
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int h = in.nextInt(); if (d > 2 * h || (n > 2 && d == 1)) { System.out.println("-1"); } else { for (int i = 1; i <= h; i++) { Sy...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
6e471416840ac91ca4ac8cd91f39d8b4
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
import java.util.Scanner; public class BearAndForgottenTree3 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int h = in.nextInt(); if (d > 2 * h || (n > 2 && d == 1)) { System.out.println("-1"); } else { for (int i = 1; i <=...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
608ef8be7e116161efa9053ae6b4bb4c
train_002.jsonl
1459182900
A tree is a connected undirected graph consisting of n vertices and nโ€‰โ€‰-โ€‰โ€‰1 edges. Vertices are numbered 1 through n.Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the treeย โ€” he can tell you only th...
256 megabytes
/*Author LAVLESH*/ import java.util.*; import java.io.*; public class solution{ static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st=new StringTokenizer(""); static public String next() { while (st == null || !st.hasMoreTokens()) { try...
Java
["5 3 2", "8 5 2", "8 4 2"]
2 seconds
["1 2\n1 3\n3 4\n3 5", "-1", "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"]
NoteBelow you can see trees printed to the output in the first sample and the third sample.
Java 8
standard input
[ "constructive algorithms", "trees", "graphs" ]
32096eff277f19d227bccca1b6afc458
The first line contains three integers n, d and h (2โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰1โ€‰โ‰คโ€‰hโ€‰โ‰คโ€‰dโ€‰โ‰คโ€‰nโ€‰-โ€‰1)ย โ€” the number of vertices, diameter, and height after rooting in vertex 1, respectively.
1,600
If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print nโ€‰-โ€‰1 lines, each with two space-separated integersย โ€“ indices of vertices connected by an edge. If there are many valid trees, print any of them. You ca...
standard output
PASSED
669c12e10a33edec689213b29156dda1
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.*; import java.util.*; public class Div2_354_C { public static int getAnswer(boolean [] binaryString, int k) { int switched = 0, i = 0, j = -1, ans = 1; for(i = 0;i < binaryString.length;i++) { while(j < binaryString.length && switched <= k) { j++; if(j < binaryString.length && binar...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
b041c4b7dfdcfe67de1899a3217530b7
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.*; import java.util.*; public class VasyaAndString { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); ...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
9f01de8585d6f39148b3d07c0037d806
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Mai { public static class FastReaderFile { Buffe...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
54386d2668b342d671a3d1d7e81b57ab
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class vasya { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in))...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
10576979b7cd94201149de4c1aa73ac8
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader fi = new InputReader(inputStream); PrintWriter out = new PrintWriter(ou...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
60a511d27c182ac84c6a1516767e471b
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { new Solver().run(); } } class Solver { FastScanner in = new F...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
a985c472e53a8aae26a3e70c369d51f0
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
// package cf676; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.InputMismatchException; public class CFC { private static final String INPUT = "8 1\n" + "aa...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
6895ca8cd547ea0b93d32092a31a7042
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
// package cf676; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.InputMismatchException; public class CFC { private static final String INPUT = "8 1\n" + "ba...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
62d8233bf5ec2ff544553e92736c0754
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static InputStream inputstream = System.in; static PrintStream output...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
022e9af48b22cffdb6d2b93a08ee9a28
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); String str = in.next();...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
f25f55007316192aea2ca29eab656296
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; public class VasyaAndString { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String str = sc.next(); int countA = 0; int countB = 0; ArrayList<Integer> IndexOfA = new ArrayList<Integer>(); ArrayL...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
72837cb763a969ddccbbc48c4bd97e93
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class VasyaandStrin { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Scanner input = new Scanner(Syst...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
d8d4b414dd82405c04f32baf4635f575
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = in.nextInt(); int max=0; int k = in.nextInt(); String s...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
4ea87db13bb15daa9f5a2f595b8dabed
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String l[]; l = bf.readLine().split(" "); int n = Integer.parseInt(l[0]); int k = Integer.par...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
befcab1b71a0482f47f4ea7dfd96d894
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class CF676C implements Runnable { public void run() { int n = nextInt(); int k = nextInt(); String s = nextWord(); int ans = getMaxStringBeauty(n, k, s); out.println(ans); out.flush(); } int getMaxStringBeauty(int n, ...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
fb1e1e8d02ac0ef5aa539affad268545
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; public class test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); String s=sc.next(); int answer=0; int l=0; int count[]=new int[2]; for(int i=0;i<s.length();i++) { count[s.charAt(i)-'a']++; if(Math.min(count[0],count[1])<=k) ...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
e895e5258e1ab17a3ec4ff2b3f6a1612
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; import java.text.*; public class A { static class Node{ int x; int y; public Node(int x,int y){ this.x=x; this.y=y; } } //public static PrintWriter pw; public static PrintWriter pw = new P...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
f6d6751d69db8f93922217583c918dc7
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.awt.List; 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.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import ja...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
0e98941b83413b66c1d09de04c27f9a0
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.awt.List; 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.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import ja...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
71bcc6850437ca76c986b69afc8f6520
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.util.*; public class Practice { static int mod = 1000000007; public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = Integer.parseInt(s.next()); int k = Integer.parseInt(s.next()); String str = s.next(); int a = 0 , b = 0, max = 0,...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
c4b277a2fefc6d7cff7ff1fc571e9ffa
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
//package com.company; import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); String ...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
d2214b28cfa1457a9924bc14daf0c533
train_002.jsonl
1464188700
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.Vasya can change no more than k characters of the original string. Wha...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputReader inputReader = new InputReader(System.in); PrintWriter printWriter = new PrintWriter(System.out, true); int n = inputReader.nextInt(); ...
Java
["4 2\nabba", "8 1\naabaabaa"]
1 second
["4", "5"]
NoteIn the first sample, Vasya can obtain both strings "aaaa" and "bbbb".In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
Java 8
standard input
[ "dp", "two pointers", "binary search", "strings" ]
0151a87d0f82a9044a0ac8731d369bb9
The first line of the input contains two integers n and k (1โ€‰โ‰คโ€‰nโ€‰โ‰คโ€‰100โ€‰000,โ€‰0โ€‰โ‰คโ€‰kโ€‰โ‰คโ€‰n)ย โ€” the length of the string and the maximum number of characters to change. The second line contains the string, consisting of letters 'a' and 'b' only.
1,500
Print the only integerย โ€” the maximum beauty of the string Vasya can achieve by changing no more than k characters.
standard output
PASSED
f3b3f8dc8fe49fca006c3015782c7345
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.*; public class main { public static void main(String [] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int cnt = 0; for(int i = 0; i < n; i++) { int a = sc.ne...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
fa49590932c0561267f558dd1398d4a1
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Forces { private static List<Integer> sport(int[] a) { List<Integer> ans = new ArrayList<>(); int n = a.length; for (int i = 0; i < n; i += 4) { if (i + 4 <= n) { int s = a[i] + a[i + 1] + a[i + 2] + a[i + 3]; ...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
0a5972355ceb76c7e9a52fbf6c61de6f
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.*; public class A54 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t>0) { int n=s.nextInt(); int a[]=new int[n]; int no=0; int nz=0; for(int i=0;i<n;i++) { a[i]=s.nextInt(); if(a[i]==0) nz++; if(a[i]==1)...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
e2a7c95e6b6b0a89c71cc93b230d6a39
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } static long nextLong() throws IOException { return Long.parseLong(nextToken()...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
73c7de89f33d15cb6080819c952f365f
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t=in.nextInt(); while(t-->0){ int n=in.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=in.nextInt(); ...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
bfe9245a0e83879a2906ac25262b16e5
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static Scanner sc=new Scanner(System.in); public static void main(String[] args) { int t=sc.nextInt(); for(int i=0;i<t;i++) { show(); } } private static void show() { int n=sc.nextInt(); int zero=0,one=0; for(int i=0;i<n;i+...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
3d92d2dda0bdfef4a6630214594179cf
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Euler { public static void main(String[] args){ FastReader in = new FastReader(); PrintWriter o = new PrintWriter(System.out); int t = in.nextInt(); while (t-- > 0) { int n = in.nex...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
a83c86c203e3526e82aeafbb1973485b
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class contest92{ static Scanner scan = new Scanner(System.in); static int t = scan.nextInt(); public static void main(String[] args){ for(int i=0; i<t; i++){ int n = scan.nextInt(); int[] arr = new int[n]; int a = 0; int v; for(int j=0; j<n; ...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
68cc48b0928dcf60b5011c512af61e70
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
//package codeforces.contest.ั1407; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /* 8 2 1 0 2 0 0 4 0 1 1 1 4 1 1 0 0 2 1 1 6 1 1 1 1 1 1 4 1 0 1 0 4 1 1 1 1 1 2 1 1 */ public class A { static void sol...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
b8b2b8b4a9929ca27cb50bcf705c3e70
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Equal { static class pair implements Comparable<pair> { int v, w; public pair(int v, int w) { this.v = v; this.w = w; } @Override public int compareTo(pair o) { ...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
09124c6d7b033723cf327deb540b0f12
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Stack; /** * * @author HP */ public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int testCases = s.nextInt(); while(testCases-- > 0) { int ...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output
PASSED
59e9618ee4a6ce888cdbedf33f7e1296
train_002.jsonl
1599575700
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ โ€” length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.lang.*; import java.util.Comparator; public class ai { InputStream is; PrintWriter out; long mod = (long)(1e9 + 7), inf = (long)(3e18); int cnt[]; void solve() throws Exception { // BufferedWriter out = new Buffe...
Java
["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"]
1 second
["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"]
NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything.
Java 8
standard input
[ "constructive algorithms", "math" ]
eca92beb189c4788e8c4744af1428bc7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) ย โ€” length of the array. The second line contains ...
1,100
For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) โ€” number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If ther...
standard output