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
bb255355fe18992fa0b41283d05bca11
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.*; public class cf271B{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int m= sc.nextInt(); int[][] matrix = new int[n][m]; int count =0; int[] primes = new int[100010]; int[] new_primes = new int[100010]; int k...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
a23d3bfba29dfbcfd52d7fd5bb13e853
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.awt.Point; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.LinkedL...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
344d94740853b55c2b92bc1be59bf026
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class B_ { static StreamTokenizer st = new StreamTokenizer(new BufferedReader( new InputStreamReader(System.in))); static int nextInt() throws IOException { s...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
d6588b6831a5602b8369c894a5efc691
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.*; import java.util.*; import java.lang.Math.*; public class Matrix1 { public static void main(String args[])throws Exception { boolean seive[]=new boolean[1000000]; Arrays.fill(seive,true); BufferedReader br=new BufferedReader(new InputStreamReader(System.i...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
d016bce4c487f67a5b141cb430b6eb4e
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import javax.swing.*; public class B { public static void main(String[] args) throws Exception { new B().solve(); // new FileInputStream(new File("input.txt")), // new PrintStream(new FileOutputStream(new File("output.txt")))); ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
63b5c6098830442f4e34e125295402d1
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Queue; import java.util.Scanner; import java.util.ArrayList; public class Main { static int d[][]; static int N; static boolean used[]; public static void ma...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
ccf0f1751b84c2c119c9c05b4e51e9c3
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { BufferedReader in; StringTokenizer st; PrintWriter out; TreeSet<Integer> sieve() { boolean[] prime = new boolean[500000]; prime[0] = prime[1] = true; for (int i = 2; i < prime.length...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
5a01c0b5fd939fdd16ccf35b91b9e062
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.*; public class PrimeMatrix271B { // WARNING: For efficiency purposes, true means is it NOT prime, false means prime private static boolean[] primesieve(int size) { // True will mean it is NOT prime boolean[] returnme = new boolean[size]; // Default in Java to all false ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
1dc52245c4a177b908d61fbf2483148f
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { int N = 100100; int INF = 1<<28; boolean[] p; int[] dp; void prime() { p = new boolean[N]; dp = new int[N]; fill(dp, 10000); for(int i=2;...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
86db47c6e43209c7578fd8da2b76ef5e
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.Date; import java.util.Scanner; public class Solution1 { /** * @param args */ public static void main(String[] args) { int length = 100005; int[] plainNumbersDistance = new int[length]; int[] plainNumber = new int [length]; for(int i=0;i<plainNumber.length;i++){ plainNumber[i] = i+1...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
cf9fdf54795cedc7f8076caf8917e20a
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.*; import java.util.*; public class ProblemB { InputReader in; PrintWriter out; boolean[] isPrime = new boolean[1000000]; int f(int a) { int k = 0; while (!isPrime[a + k]) k++; return k; } void solve() { int n = in.nextInt(); int m ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
22bf06108d3d1f635850f9998f862a9d
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; /** * * @author DELL */ public class PrimeMatrix { public static ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
2c2ae107fb04ff5e1198e6003a7e2b59
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { private Scanner sc = new Scanner(System.in); private static double EPS = 1e-9; private static final int INF = Integer.MAX_VALUE; public static void main(String[] args) { new Main().run(); } private void run() { ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
f6c662bad1bb6d449fef489d676600ad
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.TreeMap; public class B { static final int MAX = 100500; public static void main(String[] args) { doIt(); } static void doIt() { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out);...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
ca486d56816ddb09c8563dd69ef86fd8
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class B { static int[][] nums; static boolean[] v; static int[] primes; public static void main(String[] args) throws IOException { Buf...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
19f0c3e80eeedf3c4b059ed5fdc03e88
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); boolean[] gh = new boolean[1000000]; for (int i = 2; i < 1000000; i++) { if (!gh[i]) { for (int j = i + i; j < 1000000; j += i) { ...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
31c0fafac458621b7caae8c9347b3054
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException { (new Main()).solve(); } public Main() { } MyReader in = new MyReader(); PrintWriter out = new PrintWriter(System.out); void solve() throws IOException { //B...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
508736a793125853102a913cf21626b9
train_000.jsonl
1360596600
You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.You are really curious about prime numbers. Let us remind you that a p...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class round166B { static BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); static StringTokenizer st = new StringT...
Java
["3 3\n1 2 3\n5 6 1\n4 4 1", "2 3\n4 8 8\n9 2 9", "2 2\n1 3\n4 2"]
2 seconds
["1", "3", "0"]
NoteIn the first sample you need to increase number 1 in cell (1, 1). Thus, the first row will consist of prime numbers: 2, 2, 3.In the second sample you need to increase number 8 in cell (1, 2) three times. Thus, the second column will consist of prime numbers: 11, 2.In the third sample you don't have to do anything a...
Java 6
standard input
[ "binary search", "number theory", "brute force", "math" ]
d549f70d028a884f0313743c09c685f1
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the number of rows and columns in the matrix, correspondingly. Each of the following n lines contains m integers — the initial matrix. All matrix elements are positive integers. All numbers in the initial matrix do not exceed 105. The numbers in the lines are...
1,300
Print a single integer — the minimum number of moves needed to get a prime matrix from the one you've got. If you've got a prime matrix, print 0.
standard output
PASSED
f14d98251dab6da37c63e5eedd28a889
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int[] x = new int[n]; int min, max; x[0] = in....
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
f0944181e9c5a765cf2e0fe22f509d92
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
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.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
f39336359ac63a5be4b6c3c64c30037e
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class C931 { public static int mod = 1000000007; public static long INF = (1L << 60); static FastS...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
dcfbf57bb41419a51eb1a79bb2b75a8d
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; public class Task931C { public static class FastScanner { protected DataInputStream dataInputStream; protected byte[] buffer = new byte[0x10000]; protected int bufferOffset; protected int bufferLength; protected b...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
dd1549c017852d4d4afbbe5cd4135fd4
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
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.io.Input...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
1cd622a97a8ee539e20f71f3c977ed38
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; import java.io.*; public class Main { static InReader in; static OutWriter out; static int ans[]; static int a[]; static int t[]; static int diff; public static void main(String args[]) throws IOException { in = new InReader(); out = new OutWriter(); ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
f0b75f0b23ad20c58d85733254fcc8d1
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { static long mod=(long)(1e+9 + 7); //static long mod=(long)998244353; ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
b360907eeb263ef2d3aec74cc5b85120
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class CFR468C { static int n, x[] = new int[100001], v = 0, kMin = (int)10e5 + 1, kMax; static int b[] = new int[200010]; static String ins[]; static double kAve = 0.; public static void main(String[] args) throws IOException { Buff...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
524089236495a7c5fba354ec349200dd
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * Built using CHelper plug-in * Actual solution is at the top */ public class LaboratoryWork { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader i...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
a4bb50063d5af42ca87898a138356b0d
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D_468 { InputStream is; PrintWriter out; int n; long a[]; private boolean oj = System.getProperty("ONLINE_JUDGE") != n...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
37cbd950e95535db56870edf7a5457b6
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.StringTokenizer; import java.io.Writer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
4b78eb429028105d03db222939f05b9d
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package codeforces; import java.util.Scanner; /** * * @author Hemant Dhanuka */ public class four68C { public static void ma...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
c1e2b691e15d3cfb01274c79f4407203
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; // atharva washimkar // May 16, 2018 public class CODEFORCES_931_C { pu...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
f96851dc01b028090a6ee508812a3bf5
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { private static int N; private static int[] array; private static int numZero, numOne, numTwo; public static void main(String[] args) throws IOException { BufferedRea...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
056934a144c6211aaec5ec6448bb66e1
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; public class r468c { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int u, v, mid; u = 100000; v = -100000; int a[] = new int[n]; for(int i = 0; i < n; i++) { int x = sc.nextInt(); a[i] = x; if(u > x) { u = x; } ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
efd7543fd18f0565a2c8ca9995058a42
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
0560469644eab594f9d3a34deb19d804
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class ProblemC { public static void main(String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
8c58a39dd14c4e5d77c96512626a4214
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; import static java.lang.Math.*; public class Sol implements Runnable { long mod = (long)1e9 + 7; void solve(int total_test_cases, InputReader in, PrintWriter w) { for (int test_case = 1; test_case <= total_test_cases; test_...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
d6093f708df20cb3a91bacbc8d51fc58
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class check { static boolean DEBUG_FLAG = false; int INF = (int)1e9; long MOD = 1000000007; static void debug(String s) { if(DEBUG_FLAG) { System.out.print(s); } } void solve(InputReader in, PrintWriter out) thr...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
8969494836bc5b7469527ef2709ee0f7
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class check { static boolean DEBUG_FLAG = false; int INF = (int)1e9; long MOD = 1000000007; static void debug(String s) { if(DEBUG_FLAG) { System.out.print(s); } } void solve(InputReader in, PrintWriter out) thr...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
3b02c857da674b4b8d54f14835c9150a
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class LaboratoryWork { void solve() { int n = in.nextInt(); int[] x = new int[n]; for (int i = 0; i < n...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
4e04acc7f76c28a4919c84552c1317bf
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class LaboratoryWork{ static int stoi(String s){return Integer.parseInt(s);} public static void main(String[] args) throws Exception{ BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
df00916ecb282cad32a26c4234a03167
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int N; static int[] X; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); X = sc.nextIntArray(N); Answer answer = solve(); System.out.println( ans...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
b8cb0e9a836bc8969f4ced1f4744f359
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * Created by vlad on 08.11.15. */ public class problemC { public void solve(Scanner in, PrintWriter out) { int n = in.nextInt(); Map<Integer, ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
2bbc9d11798d40e8b45f677eb0ab3aa1
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.io.*; import java.util.*; public class CF931_D2_C{ public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt(); long sum=0; int [] arr=new int [n]; TreeMap<Integer, Integer> map=new TreeMap<Integer, Int...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
9f55ce8de23c8924b0bf20952b9e913c
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; import java.io.*; public class C931 { public static void main(String[] args) throws Exception { int n = Integer.parseInt(in.readLine()); TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(); st = new StringTokenizer(in.readLine()); for (int i = 0; i < n; i++) { int j = i...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
93db2e1c4b014a8c6c1e54b3273cb3da
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; import java.text.*; import java.io.*; import java.math.*; public class code5 { InputStream is; PrintWriter out; static long mod=pow(10,9)+7; static int dx[]={0,0,1,-1},dy[]={1,-1,0,0}; ArrayList<Integer> al[]; void solve() throws IOException { int n=ni(); int a[]=na(n); Arrays.sort(a); ...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
926b8b5790bc5caa41759c87cde50be0
train_000.jsonl
1520177700
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each o...
256 megabytes
import java.util.*; import java.io.*; public class cfr468c { public static void main(String[] args) { Scanner kb=new Scanner(System.in); int n=kb.nextInt(); int[] a=new int[n]; TreeMap<Integer,Integer> tm=new TreeMap<Integer,Integer>(); for(int i=0;i<n;i++){ a[i]=kb.nextInt(); if(!tm.containsKey(a[i])...
Java
["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9"]
1 second
["2\n0 0 0 0 0 0", "3\n101 100 100", "5\n-10 -10 -9 -9 -9 -9 -9"]
NoteIn the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to ma...
Java 8
standard input
[ "implementation", "math" ]
dbbea6784cafdd4244f56729996e9187
The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among valu...
1,700
In the first line print the minimum possible number of equal measurements. In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values,...
standard output
PASSED
100fbbb306ecb3efde4220b8f2c42bd2
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; public class Main { static List<Integer> g[];static int vis[]; static int col[]; static int par[]; static long k=998244353; static boolean at[]; static int low[];static int disc[]; static int t=0; static int n1=0,n2=0; public static void main(String[] a...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
096eee14930d7b61aa73fd72bb47b032
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @SuppressWarnings("unchecked") public class D1093 { final int mod = 998244353; ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
17efe198f15a9a9957ca62b93a0d2973
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.util.*; public class Main { public static int mod = 998244353; public static class Node { public Node(int index) { this.index = index; } public List<Node> neighbors = new ArrayList<>(); public int index; } public static void main(String[] arg...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
d4a366f76e98f588613f8698fa858ea7
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import org.omg.CORBA.MARSHAL; import java.awt.event.InputEvent; import java.awt.image.AreaAveragingScaleFilter; import java.io.*; import java.net.CookieHandler; import java.util.*; import java.math.*; import java.lang.*; public class Main implements Runnable { static class InputReader { private InputStre...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
7d66762038df935ef33108019da866ab
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.util.*; import java.io.*; public class waw{ static HashMap<Integer,Node> luckup = new HashMap<Integer,Node>(); public static class Node{ int id; int nb; LinkedList<Integer> neighbers = new LinkedList<Integer>(); public Node(int i){ id = i; ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
a40c5d001cf9e12aa5bc8d1238998b41
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class Main extends Thread { boolean[] prime; FastScanner sc; PrintWriter pw; long startTime = System.currentTimeMillis(); final class FastScanner { BufferedReader br; StringTokenizer st; pu...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
900b246d3e72ab6f4ea0d434f89bea94
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; public class D { long mod = 998244353; void solve() { int t = in.nextInt(); for (int tt = 0; tt < t; tt++) { int n = in.nextInt(); int m = in.nextInt(); ArrayList<ArrayList<Integer>> adj = new ArrayList<>(); ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
8d481150b3de1af666d8d678d88007f6
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
// package BigD; import java.util.*; import java.io.*; import java.lang.reflect.Array; import java.math.*; public class Main { static int[] color; static ArrayList G[]; static int[] num, pw; public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = (int)3e5 + 10, M = 9982443...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
09cdb297a2e43faea4c10d3158c503cf
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
// package test1; import java.util.*; import java.io.*; import java.lang.reflect.Array; import java.math.*; public class Main { private static StringTokenizer ST; private static BufferedReader BR; private static PrintWriter PW; static int[] color; static ArrayList<Integer> G[]; static int[] num, pw; publ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
34bbce235f10a36497db23602a903b92
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; public class A { static ArrayList<Integer>[]adj; static int []col; static int MOD=998244353; static int ones; static int dfs(int u) { int ans=1; for(int v:adj[u]) if(col[v]==-1) { col[v]=col[u]^1; if(col[v]==1) ones++; int tmp=dfs(v); if(tmp==-1) ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
0b80b81e4f6e44e9c2f5c12c012c9236
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class B { String fileName = ""; ////////////////////// SOLUTION SOLUTION SOLUTION ////////////////////////////// long INF = Long.MAX_VALUE / 1000; long MODULO = 998244353 ; int[][] s...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
c38ddf9b1c5891fefb157360746da4a7
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
49d0c4e6f22bae600e89025138afd7e6
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.regex.*; public class Main { public static ArrayList a[]=new ArrayList[300001]; static boolean visited[]; static Vector<Integer>id=new ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
291a086afc25f1bb88654a419a01204b
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unchecked") public class C{ static int maxN=300000; static List<Integer>[] g; static int[] color,count; public static long power(long a,int n){ long res=1; while(n>0){ if(n%2==1){ res=(res*a)%M; ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
7309b76a232c2ab68707054a6d1cbfed
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
// Author @ BlackRise :) // // Birla Institute of Technology, Mesra// import java.io.*; import java.util.*; public class beautifulGraph { static int b=0,sz=0; static int mod=998244353; static long power[]=new long[4*100005]; static long ans = 1; static void Blackrise() { ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
d026dc24f80d51afc54a93b58bf105ac
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import static java.u...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
a9bef1da8ab795629bd2a6a930288e43
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; public class BeautifulGraph { public static void main (String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(in.readLine()); StringBuilder sb = new StringBuilder(); for (int t = 0; t < T; t++)...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
530071640603f1880d24ee298ba19867
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.util.*; import java.io.*; //import javafx.util.Pair; public class Main implements Runnable { static class Pair implements Comparable <Pair> { int x,y,wt; Pair(int x,int y,int wt) { this.x=x; this.y=y; this.wt=wt; } ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
4ba82f71f179400eafa07fab1b378988
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class CF1093D { class Graph { int n, ones, zeros; List<Integer>[] adj; public Graph(int nn) { adj = new ArrayList[n = nn]; for(int i = 0 ; i < n ; i++) adj[i] = new ArrayList<>(); } void add(int u, int v) { adj[u].add(v); adj[v...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
c9c7c048c1321cd9e4343cc6ffb9c3d6
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
49b9ca7442df4117a9ced84e8a0f97e5
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { private FastScanner scanner = new FastScanner(); public static void main(String[] args) { new Main().solve(); } List<List<Integer>> gr = new ArrayList<>(); ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
6d0fb69c98c278f093606195f2e28e2a
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { FastScanner in; PrintWriter out; void run() { in = new FastScanner(); out = new PrintWriter(System.out); problem(); out.close(); } class FastScanner { BufferedReader ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
b7d2bea3dc70e57587016915f829a539
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.UncheckedIOException; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.Input...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
578b054d889b55fc1f54fc1fecb87b96
train_000.jsonl
1544884500
You are given an undirected unweighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges.You have to write a number on each vertex of the graph. Each number should be $$$1$$$, $$$2$$$ or $$$3$$$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.Calculate the...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static void main (String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); String[] temp=br.readLine().trim().split(" "); int numTestCases=Integ...
Java
["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["4\n0"]
NotePossible ways to distribute numbers in the first test: the vertex $$$1$$$ should contain $$$1$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$3$$$, and $$$2$$$ should contain $$$2$$$; the vertex $$$1$$$ should contain $$$2$$$, and $$$2$$$ should contain $$$1$$$; the vertex $$$1$$$ ...
Java 8
standard input
[ "dfs and similar", "graphs" ]
332340a793eb3ec14131948e2b6bdf2f
The first line contains one integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^5$$$) — the number of tests in the input. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$$$) — the number of vertices and the number of edges, respectively. Next $$$m$$$ l...
1,700
For each test print one line, containing one integer — the number of possible ways to write numbers $$$1$$$, $$$2$$$, $$$3$$$ on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo $$$998244353$$$.
standard output
PASSED
dd54e94a54d1e9d7d8e85172f762f635
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
ed852a0aca2104073d6fcf1671d5243c
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Kraken7 */ public class Main { public sta...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
ede584000a7adef05a124f4ea86a7148
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Objects; import java.util.Random; import java.util.StringTokenizer; publi...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
9a7d0c4d20834a42626d7b506a9aad51
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class codechef { public static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(InputStream st) { this.str...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
d35789e2f79873df1bdb8a46f077d786
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.util.*; import java.io.*; public class File { public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
0be78e7d149d96121271c36a894befd5
train_000.jsonl
1566311700
The main characters have been omitted to be short.You are given a directed unweighted graph without loops with $$$n$$$ vertexes and a path in it (that path is not necessary simple) given by a sequence $$$p_1, p_2, \ldots, p_m$$$ of $$$m$$$ vertexes; for each $$$1 \leq i &lt; m$$$ there is an arc from $$$p_i$$$ to $$$p_...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; impo...
Java
["4\n0110\n0010\n0001\n1000\n4\n1 2 3 4", "4\n0110\n0010\n1001\n1000\n20\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "3\n011\n101\n110\n7\n1 2 3 1 3 2 1", "4\n0110\n0001\n0001\n1000\n3\n1 2 4"]
2 seconds
["3\n1 2 4", "11\n1 2 4 2 4 2 4 2 4 2 4", "7\n1 2 3 1 3 2 1", "2\n1 4"]
NoteBelow you can see the graph from the first example:The given path is passing through vertexes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$. The sequence $$$1-2-4$$$ is good because it is the subsequence of the given path, its first and the last elements are equal to the first and the last elements of the given path respectiv...
Java 11
standard input
[ "dp", "graphs", "greedy", "shortest paths" ]
c9d07fdf0d3293d5564275ebbabbcf12
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of vertexes in a graph. The next $$$n$$$ lines define the graph by an adjacency matrix: the $$$j$$$-th character in the $$$i$$$-st line is equal to $$$1$$$ if there is an arc from vertex $$$i$$$ to the vertex $$$j$$$ else it is equal...
1,700
In the first line output a single integer $$$k$$$ ($$$2 \leq k \leq m$$$) — the length of the shortest good subsequence. In the second line output $$$k$$$ integers $$$v_1$$$, $$$\ldots$$$, $$$v_k$$$ ($$$1 \leq v_i \leq n$$$) — the vertexes in the subsequence. If there are multiple shortest subsequences, print any. Any ...
standard output
PASSED
8c37793b552f38f3ce96c2e1359a9212
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; public class TT { public static void main(String args[]) { Scanner get=new Scanner(System.in); int n=get.nextInt(); int a[]=new int[n]; int ans[]=new int[n]; for(int i=0;i<n;i++) a[i]=get.nextInt(); int max=a[n-1]; int maxi=n-1; for(int i=a.length-1;i>=0;i--) { if...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
086abad4a9630e0792e79479b89de44c
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; public class PB { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Communication S=new Communication(); int n=S.i(); int[] a=S.is(); int M=0; for(int i=n-1;i>-1;i--){ if(a[i]>M){ M=a[i]; a[i]=0; }else{ ...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
bd30d9a3571bbc10e29ee8acb8e00155
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; public class LuxHourses { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] hs = new int[n]; for(int i = 0; i < n; i++) { hs[i] = s.nextInt(); } int[] lux = new int[n]; int max = 0; for(int i = n-1; i >= 0; i-...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
80b99755076246c5e0ea4030f28967fc
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.*; import java.util.*; public class Solver{ public static void main(String args[]){ try{ Scanner sc = new Scanner(System.in); int T = sc.nextInt(); int values[] = new int[T]; int floors[] = new int[T]; for (int i = 0; i < T; i++) values[i] = sc.nextInt(); int max = values[T -...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
ca1b206e11d82449c54e7d7f757024d1
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.lang.*; import java.io.*; import java.util.*; public class Houses { public static void main(String[] args) throws java.lang.Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(o...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
c70476ebfbf2e42d2a6c85413bec0e41
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class B { int n; long h[]; void readInput() throws NumberFormatException, IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //Scanner sc = new Scann...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
439889153a8d8bd828c2a230f951ad4d
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import static java.lang.System.in; import java.io.IOException; public class B { public static void main(String[] args) throws IOException { InputReader in = new InputReader(); int n = in.readInt(); int[] arr = new int[n]; for(int i =0;i<n;i++) { arr[i]=in.readInt(); } int maxi[] = new int[n+1]; f...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
362ad9166b22914e59fc93ea9cf950a0
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class DevelopingSkill { public static void main(String args[]) throws IOException { @SuppressWarnings("resource") Scanner sc=new Scan...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
fbc927a31bf8eb2ba4f49a45c69d83be
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class DevelopingSkill { public static void main(String args[]) throws IOException { @SuppressWarnings("resource") Scanner sc=new Scan...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
d2fcc3e15ff22aaa1835853b69ac0639
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class Solution { public static void main(String[] args) { new Solution().run(); } private void run() { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int[] h = ne...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
472d449073a131dbbc2501bab7abcacd
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.*; import java.util.Scanner; public class Solution2{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int MAXN = 100003; int n; n = sc.nextInt(); int[] rmax = new int[MAXN]; int[] arr = new int[MAXN]; int[]...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
dcc4476ebc5065e50e38f6d6f0e79540
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.*; import java.util.Locale; import java.util.StringTokenizer; public class Main implements Runnable { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
ecb033109587ead6831e1c11974bd895
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String [] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int array[] = new int[n]; StringTokenizer st = new StringTokenizer(br.readLine()); fo...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
e637b5b4c0250b83280bb9112598f0e5
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.*; public class B581 { public static void main(String[] args) { InputStream inputStream...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
ee77a38f88c46e76e765acb6da4ebdca
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; public class mainClass { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n= in.nextInt(); int [] floors =new int[100000]; for(int i=0;i<n;i++) { floors[i]=in.nextInt(); } int[] out = new int[100000];...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
6b294ce17c5652c04932f5107ada1fd5
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class floors { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int c[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } in...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
cc7619fd257f57a0b1add2bc72842526
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.*; import java.util.*; public class main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static String next() throws IOException{ while ( tok == null || !tok.hasMoreTokens()){ tok = new StringTokenizer(in.readLine()); } return tok.nextT...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
d4f44158fd5f243634d829c14b32ca58
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; public class LuxuriousHouses { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int numOfHouse = sc.nextInt(); int[] floors = new int[numOfHouse]; for(int i=0; i<numOfHouse; i++){ floors[i] = sc.nextInt(); ...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
27768c6700bd3917cb6254e7a79bca92
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.Scanner; import java.util.TreeMap; import java.util.TreeSet; import java.io.IOException; import java.io.PrintWriter; 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.Hash...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
df2ee48180ab7250c7b7adfc45234a3d
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.*; public class CF581B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i ++) a[i] = in.nextInt(); int max = a[n -1] - 1; for(int i = n - 1; i > -1; i --) { int t = a[i]; a[i] = M...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
7bc913785b91a5c0fe3ff91c28ccc1af
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.*; import java.util.*; public class b1 { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int h[] = new int[n]; for (int i = 0; i < n; i++) { h[i] = in.ne...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
4c90e7ad7ec4b68c92ed5ab48f072ef7
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class Codeforces { StringTokenizer tok; B...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
0b4c1b20aad7b3bea052a614fa2fba31
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.util.*; import java.lang.Math; public class Sample1 { public static void main(String args[]){ int n; long h[], maxr; h = new long[100000]; Scanner sc = new Scanner(System.in); n = sc.nextInt(); for(int i = 0; i < n; i++){ h[i] = sc.nextInt(); ...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output
PASSED
a26389d3ec1b2257e023f5754add2d16
train_000.jsonl
1443430800
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Codeforces581B { public static void main(String[] args) { try { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int n...
Java
["5\n1 2 3 1 2", "4\n3 2 1 4"]
1 second
["3 2 0 2 0", "2 3 4 0"]
null
Java 7
standard input
[ "implementation", "math" ]
e544ed0904e2def0c1b2d91f94acbc56
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.
1,100
Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.
standard output