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
388f804995ec2a9563a2217d4ffdd498
train_001.jsonl
1327215600
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; public class E { static int[] L; static long[] Fac; static long[] InvMod; st...
Java
["3 2\n10 10 10", "4 2\n4 4 7 7"]
2 seconds
["3", "4"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
Java 6
standard input
[ "dp", "combinatorics" ]
c421f47149e70240a02903d9d47de429
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
2,100
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
standard output
PASSED
8915cff129f0fd683249ca65c137a30f
train_001.jsonl
1327215600
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.HashMap; /...
Java
["3 2\n10 10 10", "4 2\n4 4 7 7"]
2 seconds
["3", "4"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
Java 6
standard input
[ "dp", "combinatorics" ]
c421f47149e70240a02903d9d47de429
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
2,100
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
standard output
PASSED
ebb490b49cf8173fc046cdb08ff23a26
train_001.jsonl
1327215600
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
256 megabytes
import java.util.*; public class E { private static Scanner sc = new Scanner(System.in); private static final int P = 1000000007; /** * @param args */ public static void main(String[] args) { int n = sc.nextInt(); int k = sc.nextInt(); int[] xs = new int[n]; ...
Java
["3 2\n10 10 10", "4 2\n4 4 7 7"]
2 seconds
["3", "4"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
Java 6
standard input
[ "dp", "combinatorics" ]
c421f47149e70240a02903d9d47de429
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
2,100
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
standard output
PASSED
a7903373d47a01203dfbd7579f65d5f0
train_001.jsonl
1327215600
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
256 megabytes
import java.util.*; public class E { private static Scanner sc = new Scanner(System.in); private static final int P = 1000000007; /** * @param args */ public static void main(String[] args) { int n = sc.nextInt(); int k = sc.nextInt(); int[] xs = new int[n]; ...
Java
["3 2\n10 10 10", "4 2\n4 4 7 7"]
2 seconds
["3", "4"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
Java 6
standard input
[ "dp", "combinatorics" ]
c421f47149e70240a02903d9d47de429
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
2,100
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
standard output
PASSED
fe41299e406d640317761d0b71db44a4
train_001.jsonl
1327215600
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
256 megabytes
import java.util.*; public class E { private static Scanner sc = new Scanner(System.in); private static final int P = 1000000007; /** * @param args */ public static void main(String[] args) { int n = sc.nextInt(); int k = sc.nextInt(); int[] xs = new int[n]; ...
Java
["3 2\n10 10 10", "4 2\n4 4 7 7"]
2 seconds
["3", "4"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
Java 6
standard input
[ "dp", "combinatorics" ]
c421f47149e70240a02903d9d47de429
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
2,100
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
standard output
PASSED
5f3e6c0436b8a15af7d32f33502b7b92
train_001.jsonl
1448382900
A function is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≀ KΒ·|x - y| holds for all . We'll deal with a more... discrete version of this term.For an array , we define it's Lipschitz constant as follows: if n < 2, if n β‰₯ 2, over all 1 ≀ i < j ≀ n In other ...
256 megabytes
//package DIV_333; import java.util.Scanner; public class D { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt() ,m=sc.nextInt(); int []a=new int[n+1]; int q[]=new int[100009]; int stk[]=new int[100009]; int pos[]=new int[100009]; long sum[]=new long[100009]; for...
Java
["10 4\n1 5 2 9 1 3 4 2 1 7\n2 4\n3 8\n7 10\n1 9", "7 6\n5 7 7 4 6 6 2\n1 2\n2 3\n2 6\n1 7\n4 7\n3 5"]
1 second
["17\n82\n23\n210", "2\n0\n22\n59\n16\n8"]
NoteIn the first query of the first sample, the Lipschitz constants of subarrays of with length at least 2 are: The answer to the query is their sum.
Java 7
standard input
[ "math" ]
e02938670cb1d586d065ca9750688404
The first line of the input contains two space-separated integers n and q (2 ≀ n ≀ 100 000 and 1 ≀ q ≀ 100)Β β€” the number of elements in array and the number of queries respectively. The second line contains n space-separated integers (). The following q lines describe queries. The i-th of those lines contains two spa...
2,100
Print the answers to all queries in the order in which they are given in the input. For the i-th query, print one line containing a single integerΒ β€” the sum of Lipschitz constants of all subarrays of .
standard output
PASSED
876729f65fe7d6e10084ef30797a345b
train_001.jsonl
1448382900
A function is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≀ KΒ·|x - y| holds for all . We'll deal with a more... discrete version of this term.For an array , we define it's Lipschitz constant as follows: if n < 2, if n β‰₯ 2, over all 1 ≀ i < j ≀ n In other ...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchEx...
Java
["10 4\n1 5 2 9 1 3 4 2 1 7\n2 4\n3 8\n7 10\n1 9", "7 6\n5 7 7 4 6 6 2\n1 2\n2 3\n2 6\n1 7\n4 7\n3 5"]
1 second
["17\n82\n23\n210", "2\n0\n22\n59\n16\n8"]
NoteIn the first query of the first sample, the Lipschitz constants of subarrays of with length at least 2 are: The answer to the query is their sum.
Java 7
standard input
[ "math" ]
e02938670cb1d586d065ca9750688404
The first line of the input contains two space-separated integers n and q (2 ≀ n ≀ 100 000 and 1 ≀ q ≀ 100)Β β€” the number of elements in array and the number of queries respectively. The second line contains n space-separated integers (). The following q lines describe queries. The i-th of those lines contains two spa...
2,100
Print the answers to all queries in the order in which they are given in the input. For the i-th query, print one line containing a single integerΒ β€” the sum of Lipschitz constants of all subarrays of .
standard output
PASSED
81c1cc27ba2da651c2eb5bf4c58d4242
train_001.jsonl
1348069500
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left). Alice...
256 megabytes
import java.util.Scanner; public class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(), t = scanner.nextInt(); int x = 0, y = 0; String s = "YES"; for (int i = 0; i < n; i++) { ...
Java
["3\n6\n3 2\n5 4\n2 4", "3\n3\n2 6\n4 1\n5 3"]
2 seconds
["YES", "NO"]
null
Java 11
standard input
[ "constructive algorithms", "greedy" ]
2d6a1202139e1f77f32377224e1fe752
The first line contains a single integer n (1 ≀ n ≀ 100) β€” the number of dice in the tower. The second line contains an integer x (1 ≀ x ≀ 6) β€” the number Bob sees at the top of the tower. Next n lines contain two space-separated integers each: the i-th line contains numbers ai, bi (1 ≀ ai, bi ≀ 6;Β ai ≠ bi) β€” the numbe...
1,100
Print "YES" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print "NO" (without the quotes).
standard output
PASSED
7b121a38c37b4005c8a9928e35aeb907
train_001.jsonl
1348069500
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left). Alice...
256 megabytes
import java.util.Scanner; public class Lol2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int x2 = Math.abs(7 - x); int test = 0; for(int i =0; i < n; i++) { int inp...
Java
["3\n6\n3 2\n5 4\n2 4", "3\n3\n2 6\n4 1\n5 3"]
2 seconds
["YES", "NO"]
null
Java 11
standard input
[ "constructive algorithms", "greedy" ]
2d6a1202139e1f77f32377224e1fe752
The first line contains a single integer n (1 ≀ n ≀ 100) β€” the number of dice in the tower. The second line contains an integer x (1 ≀ x ≀ 6) β€” the number Bob sees at the top of the tower. Next n lines contain two space-separated integers each: the i-th line contains numbers ai, bi (1 ≀ ai, bi ≀ 6;Β ai ≠ bi) β€” the numbe...
1,100
Print "YES" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print "NO" (without the quotes).
standard output
PASSED
ab8533842022d78ddeb3a60b41a2daf7
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; i...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
c8070b50f0bab15086704943336c78e4
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
//package com.company; // Always comment out package when submitting. import java.io.*; import java.util.*; public class Main { // Actual Code public static class Task { public void solve(Scanner sc, PrintWriter pw) throws IOException { int k = sc.nextInt(); int n = 2000; ...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
c922e21af470016b9fcec9bd51935711
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Arr...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
49751566f51f7f5fe6044039714793d1
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author beginner1010 */ public cla...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
4d3701a72c94853431de2e78d59dedd5
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
f0ef0da6849cf481a9332a2a4d586c03
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void main(String[] args) { new E(); } public E() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int T = 1; while(T-->0) { int K = fs.nextInt(); int[] arr = new int[1999]; arr[0...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
ebc05ce628d19d55ec39825fa1291b00
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.*; import java.util.*; public class B implements Runnable { public static void main (String[] args) {new Thread(null, new B(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println(""); int k = f...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
c6a00d8d02209b1330566b647b8eed35
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.io.*; import java.util.*; public class CFB { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy = {1, 0, -1, 0}; private...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
32571960d84c0592706f67009185e3ff
train_001.jsonl
1551022500
Consider the following problem: given an array $$$a$$$ containing $$$n$$$ integers (indexed from $$$0$$$ to $$$n-1$$$), find $$$\max\limits_{0 \leq l \leq r \leq n-1} \sum\limits_{l \leq i \leq r} (r-l+1) \cdot a_i$$$. In this problem, $$$1 \leq n \leq 2\,000$$$ and $$$|a_i| \leq 10^6$$$.In an attempt to solve the prob...
256 megabytes
import java.util.*; import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; public class B { FastScanner in; PrintWriter out; boolean systemIO = true; public static void quickSort(int[] a, int from, int to) { if (to - from <= 1) { return; } int i = from; int j = to - 1; int x ...
Java
["8", "612"]
1 second
["4\n6 -8 7 -42", "7\n30 -12 -99 123 -2 245 -300"]
NoteThe first sample corresponds to the example given in the problem statement.In the second sample, one answer is $$$n = 7$$$ with $$$a = [30, -12, -99, 123, -2, 245, -300]$$$, in which case find_answer(n, a) returns $$$1098$$$, while the correct answer is $$$1710$$$.
Java 8
standard input
[ "constructive algorithms" ]
df7e4272ea2b48a5ad5f35a05c79044c
The first and only line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^9$$$).
2,000
If there is no sought sequence, print "-1". Otherwise, in the first line, print one integer $$$n$$$ ($$$1 \leq n \leq 2\,000$$$), denoting the number of elements in the sequence. Then, in the second line, print $$$n$$$ space-separated integers: $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$|a_i| \leq 10^6$$$).
standard output
PASSED
81c11ff08679eb6a751399bf4854389d
train_001.jsonl
1539269400
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
2 seconds
["6", "150352234", "1"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
Java 8
standard input
[ "combinatorics", "strings" ]
385ac4db5b0e7613b03fb4f1044367dd
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
2,300
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
standard output
PASSED
f175646c5a668e5026746ab2b05030aa
train_001.jsonl
1539269400
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class D { // Exponentation public static int exp(int base, int e, int mod) { if(e == 0) return 1; if(e == 1) return base; int val = exp(base, e/2, mod); int ans = (int)(1L*val*val % mod); if(e % 2 ==...
Java
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
2 seconds
["6", "150352234", "1"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
Java 8
standard input
[ "combinatorics", "strings" ]
385ac4db5b0e7613b03fb4f1044367dd
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
2,300
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
standard output
PASSED
a7e3ec94778de13191f1781510ee2088
train_001.jsonl
1539269400
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
256 megabytes
import java.io.*; import java.util.*; public class CF1065E { static final int MD = 998244353; static long power(int a, int k) { if (k == 0) return 1; long p = power(a, k / 2); p = p * p % MD; if (k % 2 == 1) p = p * a % MD; return p; } public static void main(String[] args) throws IOException { B...
Java
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
2 seconds
["6", "150352234", "1"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
Java 8
standard input
[ "combinatorics", "strings" ]
385ac4db5b0e7613b03fb4f1044367dd
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
2,300
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
standard output
PASSED
3eaeb00ccb2406fe973d4886e91e9012
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
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.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHel...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
1ac8537e8e9bba75f4e635b143165c3f
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.util.function.BinaryOperator; public class Main { private final static long mod = 1000000007; private final static int MAXN = 1000001; private static long power(long x, long y, long m) { long temp; if (y =...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
3683fd225b976f4c200c469a2c995221
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class CodeForce{ public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0){ String[] str=b...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
b5608aa8d371505203c4d0f9229ea253
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.Scanner; public class Main { public static long count(int len, int g, int b){ int gd = (int) Math.ceil((double) len / 2); int period = g + b; if (gd < g) return (long) len; else{ int n = (int) Math.floor(gd / g); if (gd % g == 0) return Math....
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
dd4d4857e53749aa9cdb7ec4e98fe83e
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class B { static final int MOD = 1000000007; // 1e9 + 7 static final boolean AUTO_FLUSH = false; // slow if true // int = num(); // long = ll(); // string = next(); // a string line = line(); // ---------------------------...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
032ea8f0dd4176332a9484cb9b122fb7
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; public class Main { private static final int INF = 2_000_000_000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder ans = new StringBuilder(); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt()...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
f0b390514a1b3a8619779eae934d8584
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class A { public void run() throws Exception { FastScanner sc = new FastScanner(); int test = sc.nextInt(); outer: for (int i = 0; i<test; i++) { long n = sc.nextLong(); long g = sc.nextLong(); long b = sc.nextLo...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
16eb65bc8da3ef91da16e2b12a1761f6
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; import java.io.*; public class NationalProject { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); while(T-->0) { String[] ...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
2cc083605518fafc9c4526081f0510d1
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.Scanner; public class B1303 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int n = scanner.nextInt(); int g = scanner.nextInt(); int b = scanne...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
335cdf57250cece72eef40bea4a7ff57
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; public class NationalProject { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t -->0) { long n = scanner.nextInt(); long g = scanner.nextInt(); long b = scanner.nextInt(); long res; long div = (n+1)/...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
5e83ebea3d54a88213390cb3f9f372a4
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.Scanner; public class fix { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt(); for(int i = 0;i<r;i++) { long n = sc.nextLong(); long g = sc.nextLong(); long b = sc.nextLong(); days(n,g,b); } } public static void days(long n,long...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
8d459d004d252ac2699ffd0d303ba849
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; public class CodeForces{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long n=sc.nextLong(); long g=sc.nextLong(); long b=sc.nextLong(); long gr=(n+1)/2; long ans=(gr/g)*(...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
1a39eec8f7b584eea82c0906edbdafdb
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn= new Scanner(System.in); int t = scn.nextInt(); while(t-->0){ int n= scn.nextInt(); int g =scn.nextInt(); int b= scn.nextInt(); System.out.println(res(n,g,b)); }...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
da8ff939b88994c0377a327bec3b4f02
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
b8b527783b9329dad1289e0dd2063e00
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; import java.util.*; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pranay2...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
40f95d96bc60a180f1754794f8774a63
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.Scanner; public class NationalProjectEduRound82B { public static void main(String[] args) { Scanner s =new Scanner(System.in); int t = s.nextInt(); while( t-- > 0) { long n = s.nextLong(); long g = s.nextLong(); long b = s.nextLong(); long half = n / 2; long ans = half; if(n ...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
46de5bf4a997130e2ed74bfd605f1e92
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void solve(InputReader in, OutputWriter out) { int n = in.readInt(), g = in.readInt(), b = in.readInt(); long res = (n+1)/2; long total = 0; if(res % g == 0) total += res + (res/g - 1)*b; else total += res + (res/g)*b; if(t...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
6030e0eb6a48ef2de361dc4656782b7b
train_001.jsonl
1581518100
Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there ...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class io2 { static long mod = (long) 1e9 + 7; static boolean multipleTC = true; void solve(int TC) throws Exception { long n = in.nl(), g = in.nl(), b = in.nl(); long hgdjf = n / 2 + n % 2; long tm = hgdjf / g, v = hgdjf % g == 0 ? 0 : 1,d = (...
Java
["3\n5 1 1\n8 10 10\n1000000 1 1000000"]
2 seconds
["5\n8\n499999500000"]
NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.
Java 8
standard input
[ "math" ]
be9138aca8e1b8a5d722f99fcd70b685
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) β€” the number of test cases. Next $$$T$$$ lines contain test cases β€” one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) β€” the length of the highway and the number of good and bad days respec...
1,400
Print $$$T$$$ integers β€” one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
standard output
PASSED
8150ad48ea7e0b0f0910f5aa81c82dc9
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class main2 { static ArrayList<pair> factors; static boolean isComposite[]; static ArrayList<Integer> primes; public static boolean isprime(long n){ if(n<=10001){ return !isComposite[(int)n]; } ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
7abeac4d10913b549ec7b44fb9bbb7c8
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
// import java.io.BufferedInputStream; // import java.util.*; // public class Main { // public static void main(String[] args) { // Scanner scan = new Scanner(new BufferedInputStream(System.in)); // // int t = scan.nextInt(); // // while(t-->0) { // int n = scan.nextInt(); // ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
b6798763a418a60e92f4c4d3ce0af457
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; public class CircleColor { static class InputReader { public BufferedReader reader; public StringTokenizer tok; public InputReader(InputStream inputStream) { reader = new BufferedReader(new InputStreamReader(inputStream)); tok ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
08670649c5c188af0acd7a47168e5fe2
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Comparator; import java.util.StringTokenizer; public class A { public static void main(String[] args) { int ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
1c26b2a5ed90da2bb5b1a4e968a3b96e
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; public class Problem1 { public static void getResult(int list1[],int list2[],int list3[]) { int list4[]=new int[list1.length]; list4[0]=list1[0]; int size=list1.length; for(int i=1;i<size;i++) { if(list1[i]==list4[i-1]) { list4[i]=list2[i]; } else l...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
5793c4a66f9f44cef68a3d2743893dd8
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; import java.io.*; public class CircleColoring { // https://codeforces.com/contest/1408/problem/A public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new BufferedR...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
523ff3663e423b2d41d2b4ea667d58f8
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); FastScanner in = new FastScanner(); int t = in.nextInt(); while(t-- >0){ int n = in.nextInt(); int[] a = in.read...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
da8108de74a020ecb3263fe91081502b
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; public class Codeforces { static boolean ab(String a[],String b[],String c[],ArrayList<Integer> ans,int n2) { //System.out.println(ans); if(ans.size()==a.length) return true; if(ans.size()==0) { ans.add(Integer.parseInt(a[0])); i...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
2240f82b344ea46af5266eabc2bbd74d
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String[] args) { FastScanner sc =new FastScanner(); PrintWriter out=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int a[]...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
045d33c53431d23aeb76f2a7b83e5924
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String[] args) { FastScanner sc =new FastScanner(); PrintWriter out=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int a[]...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
736b9b13756227d5856d0d964cf11d97
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = Syste...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
1fbaaf77eb60b54b720c19ab8137f64a
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { // write your code here FastScanner f = new FastScanner(); int t = f.nextInt(); for(int tt=0;tt<t;tt++) { ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
23b543cb7cdb76ca44638c01c5099634
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedLi...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
c405b6cda76773b4601b96a5ab33f4e2
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; public class Codef { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for (int i = 0; i < t; i++) { int n=sc.nextInt(); int a[]=new int[n]; int c[]=new int[n]; int b[]=new int[n]; for(int j=0;j...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
a7845fc29a4803d989e51a20bce4679b
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; public class Rough { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); StringTokeni...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
381f10fac94472052665a6972a8a0105
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import static java.lang.Integer.min; import static java.lang.Long.max; import static java.lang.Long.min; public final class Main { static FastScanner in=new FastScanner(); static PrintWriter out=new PrintWriter(System.out); ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
c2f3e56ab44a03393c36b63722ca2c5f
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); P...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
c830867cc2b6165d0b61334ee5e922e6
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Coding { static long MOD = 998244353; static long[] fact = new long[302]; static long[] invFact = new long[302]; static long[][][] segmentTree = new long[4*300000 + 11][2][2]; static long MINVALUE = Int...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
9adc7f11cb8f757cb4d56dcbf236c5b8
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); for (...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
c1cf43a84e754d0922760701cba0a2d0
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); int z=1; while(t-->0){ int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int c[]=new int[n]; f...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
3e99f5de77b7b3b025904d1df05fcd2c
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; public class Main{ 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]; int b[]=new int[n]; int c[]=new int[n]; for(int i=0;i<n;i++){ ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
f781b2ab0d77118b1f2ade7e2b5f97ba
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.Scanner; /** * * @author Shivam Patel */ public class CircleColoring { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int i = 0; i < test; i++) { int seq = sc.nextInt(); int[] a = new...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
05662f71a5b8d394d899ea4803e5b1bf
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fcking inter...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
ceeced11735d7f985ba8b2731010a7c2
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; import java.io.*; public class _1408A { static int[] MODS = {1000000007, 998244353, 1000000009}; static int MOD = MODS[0]; public static void main(String[] args) { sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.next...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
f92e7dcf5257a8ec60c8145295a7e4db
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.*; import java.math.BigInteger; public class A{ publ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
f45b8dd291bc721526a959bb0880012e
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.TimeUnit; public class aGrakn implements Runnable{ public static void main(String[] args) { try{ new Thread(null, new aGrakn(), "process", 1<<26).start(); } catch(Exception e){ System.out.println(e); ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
2ee8274553c9fddf228dc9aa651e489c
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Prac{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; p...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
4e77ddfae818dd55adeb9c62acb29b61
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class codeForces { public static void main(String args[]) { StringBuilder ans=new StringBuilder();; FastReader in=new FastReader(); int T=in.nextInt(); while(T-->0) {...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
0a95264694d4ef700b13b6a9887027f9
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(), prev = 0, first = 0; int[][] v = new int[n][3]; for (int j = 0; j < n; j++) { v[...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
3d1ae9615108eb819eef608b64f46c10
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int i=0;i<t;i++) { int n=s.nextInt(); int[] arr=new int[n]; int[] brr=new int[n]; int[] crr=new int[n]; fo...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
180f5832b4d04de58098605732dcb326
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
//package CodeForces; import java.io.*; import java.util.*; import javafx.util.Pair; public class Main { public class Haha { /* _____ ___ /\ /\ | | | | /\ /\ /\ /\ /\ ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
7b9cdc07196d368f1117b59b94d994d1
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.util.Scanner; public class Solution1 { public static void main(String[] args) { Solution1 s = new Solution1(); Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-- > 0) { s.solve(sc); System.out.println(); } sc.close(); } public void solve(Scanner sc) { int N = ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
3109f3ba0d0c717e47111af368547e12
train_001.jsonl
1601476500
You are given three sequences: $$$a_1, a_2, \ldots, a_n$$$; $$$b_1, b_2, \ldots, b_n$$$; $$$c_1, c_2, \ldots, c_n$$$.For each $$$i$$$, $$$a_i \neq b_i$$$, $$$a_i \neq c_i$$$, $$$b_i \neq c_i$$$.Find a sequence $$$p_1, p_2, \ldots, p_n$$$, that satisfy the following conditions: $$$p_i \in \{a_i, b_i, c_i\}$$$ $$$p_i \ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CF1408A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); ...
Java
["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3"]
1 second
["1 2 3\n1 2 1 2\n1 3 4 3 2 4 2\n1 3 2\n1 2 3 1 2 3 1 2 3 2"]
NoteIn the first test case $$$p = [1, 2, 3]$$$.It is a correct answer, because: $$$p_1 = 1 = a_1$$$, $$$p_2 = 2 = b_2$$$, $$$p_3 = 3 = c_3$$$ $$$p_1 \neq p_2 $$$, $$$p_2 \neq p_3 $$$, $$$p_3 \neq p_1$$$ All possible correct answers to this test case are: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]...
Java 8
standard input
[ "constructive algorithms" ]
7647528166b72c780d332ef4ff28cb86
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 100$$$): the number of elements in the given sequences. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \l...
800
For each test case, print $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$p_i \in \{a_i, b_i, c_i\}$$$, $$$p_i \neq p_{i \mod n + 1}$$$). If there are several solutions, you can print any.
standard output
PASSED
0cc242cd47f21e6e1d41847d8c17ed74
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; import java.io.*; public class Round135 { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int k = sc.nextInt(); Strin...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
b957f775ba6896e066331f3bc978cb14
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class Kstring { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); String cad = sc.next(); int[] ar = new int[26]; boolean correcto = true; String cadFin = ""; for(int i=0; i<cad...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
ed66f11bbd663b0161429f550e45c4bc
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import static java.util.Arrays.copyOfRange; import static java.util.Arrays.sort; import java.io.*; import java.util.*; public class A { static void solve() throws IOException { int k = nextInt(); char[] c = nextToken().toCharArray(); String res = get(c, k); if (res == null) { out.println("-1"); } else ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
7e42a86880bfac12b72a7da9b3cfe210
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class k_String { public static void main(String[] args) { Scanner input = new Scanner(System.in); int k = input.nextInt(); input.nextLine(); String s = input.nextLine(); final int NUMOFCHARS = 26; int[] num = new int[NUMOFCHARS]; for (int i = 0; i < NUMOFCHARS; ++i) {...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
6ec302b3d149fc7503867e74b1b70cd3
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; public class A219 { public static void main(String[] args){ Scanner br = new Scanner(System.in); int k = br.nextInt(); String line = br.next(); int[] freq = new int[26]; for(int i = 0;i<line.length();i++){ freq[line.charAt(i)-'a']++; } ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
3b037898eb1117944ae7ca55241f7003
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class A_219_k_String { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); char s[] = sc.next().toCharArray(); int a[] = new int[255]; for (int i = 0; i < s.length; i++) { a[s[i]]++; } for (int i = 'a'; i <= 'z'; i++) { ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
49c913f64c6e0efe0d2553cd58a4f569
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try { Parserdoubt pd=new Parserdoubt(S...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
41f134db6cb3f7ac0d1c47b4f393bc0a
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.*; import java.util.*; public class test1 { public static void main(String[] args) throws Exception { new test1().run(); } PrintWriter out = null; void run() throws Exception { Scanner in = new Scanner(System.in); out = new PrintWriter(System.out); ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
7e6278741a86c7a54d68e66ef76cf2da
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int k = s.nextInt(); s.nextLine(); String w = s.nextLine(); int[] cc = new int[26]; for (int j = 0; j < w.length(); ++j) cc[(w.charAt(j) - 'a')]++; StringBuffer out =...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
89fda8e44edd83c28c8efdcafc5056f5
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String line = in.next(); int letters[] = new int[26]; for(int i=0;i<line.length();i++) letters[line.cha...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
585ebdd2fef2fabfcb18c8b6e7518d1c
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.*; import java.util.*; public class KString{ BufferedReader in; PrintWriter out; StringTokenizer st; public void run() throws Exception { //in = new BufferedReader(new FileReader("D.IN")); in = new BufferedReader(new InputStreamReader(System.in)); out = new Print...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
18970ca99557bfc0eb3b96156137d7ab
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Locale; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeMap; public class CFA { BufferedReader in; StringTok...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
6ddb479513b7c0368944f3ca059dd5a4
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Problem219A { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
3c255c7124b14a883e79f5354ed6ea92
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class main { public static void main(String[] args) { Scanner s= new Scanner(new BufferedReader(new InputStreamReader(System.in))); //BufferedReader n = new BufferedReader(new InputStreamR...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
0df4ab35fa9ce03dab1ae56a9d994764
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { static int INF = Integer.MAX_VALUE; public static void main(String args[]){ Scanner s = new Scanner(System.in); int k = s.nextInt(); int count[] = new int[150]; Str...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
f3e17e8551fb1575c65f5e82ac40cb66
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.*; import java.util.*; public class CodeForce { private void solve() throws IOException { final int K = nextInt(); int []C = new int[26]; final String line = nextLine(); Set<Character> ccs = new HashSet<Character>(); for(char c : line.toCharArray()) { ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
a7c9d5889458fdf07e88d1454b39ff03
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; /************************************************************************* * 219D Codeforce * *************************************************************************/ public class Sourcecode { public static void main (String[] args) { Scanner scan=new Scanner(Sy...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
0fdf78ffec96c562dbc840c4bbbfbb3d
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; import java.io.*; public class A { public void solve() throws IOException { int n = nextInt(); String str = nextToken(); int[] letter = new int[26]; for(int i = 0; i < str.length(); i++){ char x = str.charAt(i); letter[(int)(x-'a')]++; } StringBuilder temp = new StringBuilder(); ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
857c7fb7a1031bd1eb8389a19dca2bb1
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; import java.io.*; public class A { public void solve() throws IOException { int n = nextInt(); String str = nextToken(); int[] letter = new int[26]; for(int i = 0; i < str.length(); i++){ char x = str.charAt(i); letter[(int)(x-'a')]++; } StringBuilder temp = new StringBuilder(); ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
ec59765bb10f6c88bf2d2cc4d6d56e23
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
//package arbuz; import java.util.Scanner; public class Arbuz { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); String s = sc.next(); int[] num = new int[26]; int i; for (i = 0; i < s.length(); i++) { ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
708b9146000a9ce26cf47700e84d1697
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class A_219 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int k = sc.nextInt(); int[] alpha = new int[26]; for(char c : sc.next().toCharArray()){ alpha[c - 'a']++; } boolean flag = true; for(int i = 0; i < 26; i...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
dbc3ff98ef717dbf08919d954bd5edd6
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.*; import java.util.*; public class KString{ public static void main(String args[])throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); String s = in.readLine(); int arr[] = ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
09205b0b98295f51882847aed0c97664
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class A implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
f528d1b0b805abfce8b10f461faf381b
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.*; import java.io.*; public class C135A { /** * @param args */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int[] w = new int[26]; if (n == 1) { ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
26e36501861b2dee1766db7b58f76f83
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class A_k_String { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n =sc.nextInt(); String s=sc.next(); int a[]=new int[30]; for (int i = 0; i < s.length(); i++) { a[(int)s.charAt(i)-96]++; } for (int i = 1; i <=26; i++...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
37677f618173e959928fe71d27b2e096
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); String s = sc.next(); if (s.length()%k != 0){ System.out.println(-1); return; } int []a = new int [...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
30c847a5fb3f8e6ff434eb03e6e6fef7
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main{ public static String res(String s ,int x){ if (x==1) return s; if ((s.length()+1)%x==0) return "-1"; char [] temp = new char [s.len...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output
PASSED
72e220e5810fa7a40b0e502a299cf82c
train_001.jsonl
1346081400
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co...
256 megabytes
import java.util.Arrays; import java.util.Locale; import java.util.Scanner; public class Codeforces2 { public static void main(String[] args){ Scanner sc=new Scanner(System.in); String k=""; int n=sc.nextInt(); String S=sc.next(); int []a=new int[255]; for(int i=0;i<255;i++) a[i]=0; ...
Java
["2\naazz", "3\nabcabcabz"]
2 seconds
["azaz", "-1"]
null
Java 6
standard input
[ "implementation", "strings" ]
f5451b19cf835b1cb154253fbe4ea6df
The first input line contains integer k (1 ≀ k ≀ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≀ |s| ≀ 1000, where |s| is the length of string s.
1,000
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).
standard output